Re: [PATCH] git-archive: convert archive entries like checkouts do
From: Daniel Barkalow <hidden>
Date: 2016-06-15 22:43:11
On Sat, 19 May 2007, René Scharfe wrote:
quoted hunk ↗ jump to hunk
diff --git a/archive-tar.c b/archive-tar.c index 56ff356..eb0abc7 100644 --- a/archive-tar.c +++ b/archive-tar.c@@ -83,11 +83,12 @@ static void strbuf_append_string(struct strbuf *sb, const char *s) int slen = strlen(s); int total = sb->len + slen; if (total > sb->alloc) { - sb->buf = xrealloc(sb->buf, total); - sb->alloc = total; + sb->buf = xrealloc(sb->buf, total + 1); + sb->alloc = total + 1;
Conditional needs a "+ 1", too.
quoted hunk ↗ jump to hunk
} memcpy(sb->buf + sb->len, s, slen); sb->len = total; + sb->buf[total] = '\0'; } /*@@ -272,18 +273,19 @@ static int write_tar_entry(const unsigned char *sha1, } if (path.alloc < baselen + filenamelen) { free(path.buf); - path.buf = xmalloc(baselen + filenamelen); - path.alloc = baselen + filenamelen; + path.buf = xmalloc(baselen + filenamelen + 1); + path.alloc = baselen + filenamelen + 1;
Same here. -Daniel *This .sig left intentionally blank*