Mercurial > dovecot > original-hg > dovecot-1.0
changeset 5507:c7456f4b0430 branch_1_0
If giving pool_alloconly_create() less than 40 bytes as the initial size
with 32bit systems, destroying the pool crashed.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 03 Jan 2008 21:20:38 +0200 |
parents | fb14b51b33f5 |
children | 1e0b273d4d64 |
files | src/lib/mempool-alloconly.c |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib/mempool-alloconly.c Wed Jan 02 23:45:40 2008 +0200 +++ b/src/lib/mempool-alloconly.c Thu Jan 03 21:20:38 2008 +0200 @@ -94,10 +94,11 @@ pool_t pool_alloconly_create(const char *name __attr_unused__, size_t size) { struct alloconly_pool apool, *new_apool; - size_t min_alloc = sizeof(struct alloconly_pool) + SIZEOF_POOLBLOCK; + size_t min_alloc = MEM_ALIGN(sizeof(struct alloconly_pool)) + + SIZEOF_POOLBLOCK; #ifdef DEBUG - min_alloc += strlen(name) + 1; + min_alloc += MEM_ALIGN(strlen(name) + 1); #endif /* create a fake alloconly_pool so we can call block_alloc() */ @@ -112,6 +113,8 @@ /* now allocate the actual alloconly_pool from the created block */ new_apool = p_new(&apool.pool, struct alloconly_pool, 1); *new_apool = apool; + /* the pool allocation must be from the first block */ + i_assert(apool.block->prev == NULL); #ifdef DEBUG if (strncmp(name, MEMPOOL_GROWING, strlen(MEMPOOL_GROWING)) == 0) { name += strlen(MEMPOOL_GROWING);