]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: data-stack - fix realloc/lowwater bug
authorPhil Carmody <phil@dovecot.fi>
Mon, 28 Jul 2014 13:45:33 +0000 (16:45 +0300)
committerPhil Carmody <phil@dovecot.fi>
Mon, 28 Jul 2014 13:45:33 +0000 (16:45 +0300)
If DEBUG is enabled, then it can try to look past the low-water mark
as the low-water mark wasn't moved during successful reallocs. This
condition is detected, and causes a panic.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
src/lib/data-stack.c

index 55c28921b6a6a8816bc24a0b38d9431d6e567c8c..5da7a8ae00995bb6c3c17c47ef0e676f8f5f7962 100644 (file)
@@ -474,6 +474,8 @@ bool t_try_realloc(void *mem, size_t size)
                if (current_block->left >= alloc_growth) {
                        /* just shrink the available size */
                        current_block->left -= alloc_growth;
+                       if (current_block->left < current_block->lowwater)
+                               current_block->lowwater = current_block->left;
                        current_frame_block->last_alloc_size[frame_pos] =
                                new_alloc_size;
                        return TRUE;