Skip to content

Commit 65d41d4

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 35eabd1 commit 65d41d4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ int unregister_shallow(const unsigned char *sha1)
225225
if (pos < 0)
226226
return -1;
227227
if (pos + 1 < commit_graft_nr)
228-
memcpy(commit_graft + pos, commit_graft + pos + 1,
228+
memmove(commit_graft + pos, commit_graft + pos + 1,
229229
sizeof(struct commit_graft *)
230230
* (commit_graft_nr - pos - 1));
231231
commit_graft_nr--;

0 commit comments

Comments
 (0)