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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Jan 29, 2010 at 05:31 UTC
7b48c170931f35c07c3ce78023519846073152a1
1 file changed
+1
-1
builtin-push.c
+1
-1
@@ -52,7 +52,7 @@ static void set_refspecs(const char **refs, int nr)
52
} else if (deleterefs && !strchr(ref, ':')) {
53
char *delref;
54
int len = strlen(ref)+1;
55
- delref = xmalloc(len);
55
+ delref = xmalloc(len+1);
56
strcpy(delref, ":");
57
strcat(delref, ref);
58
ref = delref;