summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2010-01-29 10:31:30 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-01-29 17:56:12 (GMT)
commit7b48c170931f35c07c3ce78023519846073152a1 (patch)
tree1f463ad3cdebbc0f45203921987085021a50be83
parentdace5dd14166ebc2b55f46695d27dce0e64c6464 (diff)
downloadgit-7b48c170931f35c07c3ce78023519846073152a1.zip
git-7b48c170931f35c07c3ce78023519846073152a1.tar.gz
git-7b48c170931f35c07c3ce78023519846073152a1.tar.bz2
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>
-rw-r--r--builtin-push.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin-push.c b/builtin-push.c
index 5df6608..5633f0a 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -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;