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>
This commit is contained in:
Jeff King 2010-01-29 05:31:30 -05:00 committed by Junio C Hamano
parent dace5dd141
commit 7b48c17093

View File

@ -52,7 +52,7 @@ static void set_refspecs(const char **refs, int nr)
} else if (deleterefs && !strchr(ref, ':')) {
char *delref;
int len = strlen(ref)+1;
delref = xmalloc(len);
delref = xmalloc(len+1);
strcpy(delref, ":");
strcat(delref, ref);
ref = delref;