strbuf: make sure buffer is zero-terminated
[gitweb.git] / strbuf.c
index bc3a0802ea7e7b1743602972de182391b4bf0b3f..73e0400596558cc37e7342437f3484d6a762c110 100644 (file)
--- a/strbuf.c
+++ b/strbuf.c
@@ -30,8 +30,10 @@ void strbuf_init(struct strbuf *sb, size_t hint)
 {
        sb->alloc = sb->len = 0;
        sb->buf = strbuf_slopbuf;
-       if (hint)
+       if (hint) {
                strbuf_grow(sb, hint);
+               sb->buf[0] = '\0';
+       }
 }
 
 void strbuf_release(struct strbuf *sb)