aboutsummaryrefslogtreecommitdiff
path: root/strbuf.c
diff options
context:
space:
mode:
Diffstat (limited to 'strbuf.c')
-rw-r--r--strbuf.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/strbuf.c b/strbuf.c
index f4201e160..cbada946c 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -111,12 +111,13 @@ void strbuf_addf(struct strbuf *sb, const char *fmt, ...)
int len;
va_list ap;
+ if (!strbuf_avail(sb))
+ strbuf_grow(sb, 64);
va_start(ap, fmt);
len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap);
va_end(ap);
- if (len < 0) {
- len = 0;
- }
+ if (len < 0)
+ die("your vsnprintf is broken");
if (len > strbuf_avail(sb)) {
strbuf_grow(sb, len);
va_start(ap, fmt);