diff --git a/strbuf.c b/strbuf.c index 0510f76c24b3b3ce66baa0f05054d3f01b960b6e..4b9e30cadcd1ff45e7d4f23b210b22006445da91 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);