Skip to content

Commit 2cfceef

Browse files
committed
Merge branch 'jk/strbuf-detach-always-non-null'
* jk/strbuf-detach-always-non-null: strbuf: always return a non-NULL value from strbuf_detach
2 parents bbbd057 + 08ad56f commit 2cfceef

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

strbuf.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ void strbuf_release(struct strbuf *sb)
4444

4545
char *strbuf_detach(struct strbuf *sb, size_t *sz)
4646
{
47-
char *res = sb->alloc ? sb->buf : NULL;
47+
char *res;
48+
strbuf_grow(sb, 0);
49+
res = sb->buf;
4850
if (sz)
4951
*sz = sb->len;
5052
strbuf_init(sb, 0);

0 commit comments

Comments
 (0)