diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2010-12-21 01:22:03 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2010-12-21 01:22:03 +0000 |
commit | 89afd774a62676944d20a0310ee40c58522e2c3e (patch) | |
tree | 2b35ffa204eb7c7e2b07198d1ab1433f44ce74b1 | |
parent | 2dd3befffd75653b5591451707b63f7343e9670c (diff) | |
download | mandoc-89afd774a62676944d20a0310ee40c58522e2c3e.tar.gz |
Sane behaviour for the growing of very small buffers:
Always grow at least to the minimum requested size.
Before this, a buffer of 1 byte was grown to 2 bytes,
which was too small and sometimes caused segfaults.
ok kristaps@
-rw-r--r-- | main.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -389,7 +389,7 @@ static void resize_buf(struct buf *buf, size_t initial) { - buf->sz = buf->sz ? 2 * buf->sz : initial; + buf->sz = buf->sz > initial/2 ? 2 * buf->sz : initial; buf->buf = realloc(buf->buf, buf->sz); if (NULL == buf->buf) { perror(NULL); |