Skip to content

Commit b8469ad

Browse files
dschogitster
authored andcommitted
test-path-utils: Fix off by one, found by valgrind
When normalizing an absolute path, we might have to add a slash _and_ a NUL to the buffer, so the buffer was one too small. Let's just future proof the code and alloc PATH_MAX + 1 bytes. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f265458 commit b8469ad

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

test-path-utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
int main(int argc, char **argv)
44
{
55
if (argc == 3 && !strcmp(argv[1], "normalize_absolute_path")) {
6-
char *buf = xmalloc(strlen(argv[2])+1);
6+
char *buf = xmalloc(PATH_MAX + 1);
77
int rv = normalize_absolute_path(buf, argv[2]);
88
assert(strlen(buf) == rv);
99
puts(buf);

0 commit comments

Comments
 (0)