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 <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King 2008-10-23 04:32:23 +00:00 committed by Junio C Hamano
parent 421b488a58
commit 1442171bc9

2
path.c
View File

@ -348,7 +348,7 @@ int normalize_absolute_path(char *buf, const char *path)
goto next;
}
memcpy(dst, comp_start, comp_len);
memmove(dst, comp_start, comp_len);
dst += comp_len;
next:
comp_start = comp_end;