summaryrefslogtreecommitdiff
path: root/strbuf.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2012-10-25 06:43:03 -0400
committerJeff King <peff@peff.net>2012-10-25 06:43:03 -0400
commit2cfceefaca16d64baecf0ba9bcd4e05229d9c31b (patch)
tree69a2c86a062be469fab032cfdb017134343a6147 /strbuf.c
parentbbbd0573895f7f79aeb1faa5c0333915947096c0 (diff)
parent08ad56f3f0c1df8f75bac84bcef0d9d0c9b4d20f (diff)
downloadgit-2cfceefaca16d64baecf0ba9bcd4e05229d9c31b.tar.gz
Merge branch 'jk/strbuf-detach-always-non-null'
* jk/strbuf-detach-always-non-null: strbuf: always return a non-NULL value from strbuf_detach
Diffstat (limited to 'strbuf.c')
-rw-r--r--strbuf.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/strbuf.c b/strbuf.c
index 0510f76c24..4b9e30cadc 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -44,7 +44,9 @@ void strbuf_release(struct strbuf *sb)
char *strbuf_detach(struct strbuf *sb, size_t *sz)
{
- char *res = sb->alloc ? sb->buf : NULL;
+ char *res;
+ strbuf_grow(sb, 0);
+ res = sb->buf;
if (sz)
*sz = sb->len;
strbuf_init(sb, 0);