diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-05-01 16:25:04 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-05-01 16:25:04 -0700 |
commit | 5ae6f5ca2f70bd7d5ca88c20f2be62bf3844af73 (patch) | |
tree | 749c3f321eee807f99a9d80d3485c19a62bcc13e | |
parent | Merge branch 'vh/git-svn-doc' (diff) | |
parent | strbuf: clarify assertion in strbuf_setlen() (diff) | |
download | tgif-5ae6f5ca2f70bd7d5ca88c20f2be62bf3844af73.tar.xz |
Merge branch 'rs/strbuf-setlen-assert'
* rs/strbuf-setlen-assert:
strbuf: clarify assertion in strbuf_setlen()
-rw-r--r-- | strbuf.h | 7 |
1 files changed, 2 insertions, 5 deletions
@@ -3,8 +3,6 @@ /* See Documentation/technical/api-strbuf.txt */ -#include <assert.h> - extern char strbuf_slopbuf[]; struct strbuf { size_t alloc; @@ -33,9 +31,8 @@ static inline size_t strbuf_avail(const struct strbuf *sb) { extern void strbuf_grow(struct strbuf *, size_t); static inline void strbuf_setlen(struct strbuf *sb, size_t len) { - if (!sb->alloc) - strbuf_grow(sb, 0); - assert(len < sb->alloc); + if (len > (sb->alloc ? sb->alloc - 1 : 0)) + die("BUG: strbuf_setlen() beyond buffer"); sb->len = len; sb->buf[len] = '\0'; } |