]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: data-stack - Use INITIAL_STACK_SIZE without growing it to nearest power
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 16 Nov 2020 13:25:36 +0000 (15:25 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Tue, 4 May 2021 07:02:35 +0000 (07:02 +0000)
src/lib/data-stack.c

index 2cb3c8f8db2a6e5db558f14d14065f7b40c82673..14e4022317ffbc4c821d64a7ae8944313e4c8aff 100644 (file)
@@ -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 */