Skip to content

Commit 1442171

Browse files
peffgitster
authored andcommitted
fix overlapping memcpy in normalize_absolute_path
The comments for normalize_absolute_path explicitly claim that the source and destination buffers may be the same (though they may not otherwise overlap). Thus the call to memcpy may involve copying overlapping data, and memmove should be used instead. This fixes a valgrind error in t1504. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 421b488 commit 1442171

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

path.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ int normalize_absolute_path(char *buf, const char *path)
348348
goto next;
349349
}
350350

351-
memcpy(dst, comp_start, comp_len);
351+
memmove(dst, comp_start, comp_len);
352352
dst += comp_len;
353353
next:
354354
comp_start = comp_end;

0 commit comments

Comments
 (0)