From fe41c21be9752d58320da3e3bc8a5ad207f414db Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Thu, 2 Apr 2009 15:02:18 +0000 Subject: [PATCH] Fix debug pool grow object to properly support delta=0 (It prints garbage for some reports) --- libdm/mm/pool-debug.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libdm/mm/pool-debug.c b/libdm/mm/pool-debug.c index 911f8e2b1..1c3d999b8 100644 --- a/libdm/mm/pool-debug.c +++ b/libdm/mm/pool-debug.c @@ -218,14 +218,19 @@ int dm_pool_begin_object(struct dm_pool *p, size_t init_size) int dm_pool_grow_object(struct dm_pool *p, const void *extra, size_t delta) { struct block *new; - size_t size = delta ? : strlen(extra); + size_t new_size; + + if (!delta) + delta = strlen(extra); assert(p->begun); if (p->object) - size += p->object->size; + new_size = delta + p->object->size; + else + new_size = delta; - if (!(new = _new_block(size, DEFAULT_ALIGNMENT))) { + if (!(new = _new_block(new_size, DEFAULT_ALIGNMENT))) { log_err("Couldn't extend object."); return 0; } @@ -237,7 +242,7 @@ int dm_pool_grow_object(struct dm_pool *p, const void *extra, size_t delta) } p->object = new; - memcpy(new->data + size - delta, extra, delta); + memcpy(new->data + new_size - delta, extra, delta); return 1; }