From 09539f3db2f1b3e24f40844d8456b06d318d0fe7 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Fri, 29 Apr 2016 13:55:33 +0300 Subject: [PATCH] lib: buffer_create_dynamic() now adds +1 to init_size --- src/lib/buffer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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; } -- 2.47.3