Code

fix memcpy of overlapping area
authorJeff King <peff@peff.net>
Fri, 29 Jan 2010 10:28:44 +0000 (05:28 -0500)
committerJunio C Hamano <gitster@pobox.com>
Fri, 29 Jan 2010 17:52:21 +0000 (09:52 -0800)
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>
commit.c

index 6393e1b36218e5f8970b0c43092b07f5d94b0bce..a51d2cd1bed0c18b26f8f8123f1dab398a5019d8 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -225,7 +225,7 @@ int unregister_shallow(const unsigned char *sha1)
        if (pos < 0)
                return -1;
        if (pos + 1 < commit_graft_nr)
-               memcpy(commit_graft + pos, commit_graft + pos + 1,
+               memmove(commit_graft + pos, commit_graft + pos + 1,
                                sizeof(struct commit_graft *)
                                * (commit_graft_nr - pos - 1));
        commit_graft_nr--;