From: Jeff King Date: Fri, 29 Jan 2010 10:31:30 +0000 (-0500) Subject: fix off-by-one allocation error X-Git-Tag: v1.7.0-rc1~10 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7b48c170931f35c07c3ce78023519846073152a1;p=git.git 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 Signed-off-by: Junio C Hamano --- diff --git a/builtin-push.c b/builtin-push.c index 5df66081a..5633f0ade 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;