From: Timo Sirainen Date: Mon, 16 Nov 2020 13:25:36 +0000 (+0200) Subject: lib: data-stack - Use INITIAL_STACK_SIZE without growing it to nearest power X-Git-Tag: 2.3.16~260 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d3e36b20b17f9891dc1874cd9a856a6b335465e1;p=thirdparty%2Fdovecot%2Fcore.git lib: data-stack - Use INITIAL_STACK_SIZE without growing it to nearest power --- diff --git a/src/lib/data-stack.c b/src/lib/data-stack.c index 2cb3c8f8db..14e4022317 100644 --- a/src/lib/data-stack.c +++ b/src/lib/data-stack.c @@ -345,7 +345,9 @@ static struct stack_block *mem_block_alloc(size_t min_size) size_t prev_size, alloc_size; prev_size = current_block == NULL ? 0 : current_block->size; - alloc_size = nearest_power(MALLOC_ADD(prev_size, min_size)); + /* Use INITIAL_STACK_SIZE without growing it to nearest power. */ + alloc_size = prev_size == 0 ? min_size : + nearest_power(MALLOC_ADD(prev_size, min_size)); /* nearest_power() returns 2^n values, so alloc_size can't be anywhere close to SIZE_MAX */