dovecot-2.2: lib: data-stack - fix incorrect pointer comparison ...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Jul 28 13:54:29 UTC 2014
details: http://hg.dovecot.org/dovecot-2.2/rev/27ceef4cbd10
changeset: 17650:27ceef4cbd10
user: Phil Carmody <phil at dovecot.fi>
date: Mon Jul 28 16:45:33 2014 +0300
description:
lib: data-stack - fix incorrect pointer comparison in t_try_realloc in DEBUG builds
When trying to work out if it's a valid realloc, we need to remember
that in DEBUG builds, we have hidden a size value (in a MEM_ALIGNED
space) before the pointer we return.
Signed-off-by: Phil Carmody <phil at dovecot.fi>
diffstat:
src/lib/data-stack.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diffs (24 lines):
diff -r 3856ea7037db -r 27ceef4cbd10 src/lib/data-stack.c
--- a/src/lib/data-stack.c Mon Jul 28 16:45:33 2014 +0300
+++ b/src/lib/data-stack.c Mon Jul 28 16:45:33 2014 +0300
@@ -454,7 +454,7 @@
bool t_try_realloc(void *mem, size_t size)
{
- size_t last_alloc_size;
+ size_t debug_adjust = 0, last_alloc_size;
unsigned char *after_last_alloc;
if (unlikely(size == 0 || size > SSIZE_T_MAX))
@@ -465,7 +465,10 @@
/* see if we're trying to grow the memory we allocated last */
after_last_alloc = data_stack_after_last_alloc(current_block);
- if (after_last_alloc - last_alloc_size == mem) {
+#ifdef DEBUG
+ debug_adjust = MEM_ALIGN(sizeof(size_t));
+#endif
+ if (after_last_alloc - last_alloc_size + debug_adjust == mem) {
/* yeah, see if we have space to grow */
size_t new_alloc_size, alloc_growth;
More information about the dovecot-cvs
mailing list