]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: buffer_create_dynamic() now adds +1 to init_size
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 29 Apr 2016 10:55:33 +0000 (13:55 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 29 Apr 2016 10:55:33 +0000 (13:55 +0300)
src/lib/buffer.c

index 7fb29076f413053e45cc6285d9c6dc71ad4c8957..aef163595f47a788c741569807f7d200227d9944 100644 (file)
@@ -137,7 +137,10 @@ buffer_t *buffer_create_dynamic(pool_t pool, size_t init_size)
        buf = p_new(pool, struct real_buffer, 1);
        buf->pool = pool;
        buf->dynamic = TRUE;
-       buffer_alloc(buf, init_size);
+       /* buffer_alloc() reserves +1 for str_c() NIL, so add +1 here to
+          init_size so we can actually write that much to the buffer without
+          realloc */
+       buffer_alloc(buf, init_size+1);
        return (buffer_t *)buf;
 }