fix memcpy of overlapping area
Caught by valgrind in t5500, but it is pretty obvious from reading the code that this is shifting elements of an array to the left, which needs memmove. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Jan 29, 2010 at 05:28 UTC
65d41d48a4e4e795d64dd7842a44d693b741bf31
1 file changed
+1
-1
commit.c
+1
-1
@@ -225,7 +225,7 @@ int unregister_shallow(const unsigned char *sha1)
225
if (pos < 0)
226
return -1;
227
if (pos + 1 < commit_graft_nr)
228
- memcpy(commit_graft + pos, commit_graft + pos + 1,
228
+ memmove(commit_graft + pos, commit_graft + pos + 1,
229
sizeof(struct commit_graft *)
230
* (commit_graft_nr - pos - 1));
231
commit_graft_nr--;