aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--strbuf.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/strbuf.h b/strbuf.h
index 1883494ca..01c5c6371 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -205,7 +205,8 @@ extern int strbuf_cmp(const struct strbuf *, const struct strbuf *);
*/
static inline void strbuf_addch(struct strbuf *sb, int c)
{
- strbuf_grow(sb, 1);
+ if (!strbuf_avail(sb))
+ strbuf_grow(sb, 1);
sb->buf[sb->len++] = c;
sb->buf[sb->len] = '\0';
}