summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2012-04-30 08:40:37 +0200
committerLubomir Rintel <lkundrak@v3.sk>2013-10-29 16:30:52 +0100
commitcea8e7abbab7ea77de6090dc6dc43ac6a3eaca65 (patch)
tree35c6880acdb6e2477b58e4608daa20ca27cfe5c0
parent185babec1a9b58f310df2ce950be4120c4f8a273 (diff)
downloaddev86-cea8e7abbab7ea77de6090dc6dc43ac6a3eaca65.tar.gz
copt: Get rid of overlapping strcpy()
Optimizer was corrupting optimized assembly file with certain strcpy() implementations: "\tcmp\tdx,b0[bp]" was turned into invalid "cmp\tdxb0[bp]". Valgrind: ==2491== Source and destination overlap in strcpy(0x804d640, 0x804d641) ==2491== at 0x40098CA: strcpy (mc_replace_strmem.c:429) ==2491== by 0x8049F57: readlist (copt.c:177) ==2491== by 0x80488D6: main (copt.c:319)
-rw-r--r--copt/copt.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/copt/copt.c b/copt/copt.c
index d744da8..9392380 100644
--- a/copt/copt.c
+++ b/copt/copt.c
@@ -174,7 +174,7 @@ static char *readline(FILE *fp)
/* Delete leading white spaces */
for (cp = buf; *cp && isspace(*cp); cp++) ;
if (cp != buf && *cp)
- strcpy(buf, cp);
+ memmove(buf, cp, strlen(cp) + 1);
return(buf);
}