Skip to content

Commit 7b48c17

Browse files
peffgitster
authored andcommitted
fix off-by-one allocation error
Caught by valgrind in t5516. Reading the code shows we malloc enough for our string, but not trailing NUL. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dace5dd commit 7b48c17

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin-push.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static void set_refspecs(const char **refs, int nr)
5252
} else if (deleterefs && !strchr(ref, ':')) {
5353
char *delref;
5454
int len = strlen(ref)+1;
55-
delref = xmalloc(len);
55+
delref = xmalloc(len+1);
5656
strcpy(delref, ":");
5757
strcat(delref, ref);
5858
ref = delref;

0 commit comments

Comments
 (0)