From: Timo Sirainen Date: Fri, 29 Apr 2016 10:55:33 +0000 (+0300) Subject: lib: buffer_create_dynamic() now adds +1 to init_size X-Git-Tag: 2.3.0.rc1~3912 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=09539f3db2f1b3e24f40844d8456b06d318d0fe7;p=thirdparty%2Fdovecot%2Fcore.git lib: buffer_create_dynamic() now adds +1 to init_size --- diff --git a/src/lib/buffer.c b/src/lib/buffer.c index 7fb29076f4..aef163595f 100644 --- a/src/lib/buffer.c +++ b/src/lib/buffer.c @@ -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; }