]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: mempool-allocfree - make static analyzer happier with pool clearing
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 13 Dec 2017 17:11:02 +0000 (19:11 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 14 Dec 2017 00:19:02 +0000 (02:19 +0200)
It was thinking that already freed memory was being accessed.

src/lib/mempool-allocfree.c

index c2ce9013608bd9876818311e3fc51cf292a65c40..66a296c92fba69dd8e9b577aa05db78785f93601 100644 (file)
@@ -225,9 +225,12 @@ static void pool_allocfree_clear(pool_t pool)
 {
        struct allocfree_pool *apool =
                container_of(pool, struct allocfree_pool, pool);
+       struct pool_block *block, *next;
 
-       while(apool->blocks != NULL)
-               pool_allocfree_free(pool, apool->blocks->block);
+       for (block = apool->blocks; block != NULL; block = next) {
+               next = block->next;
+               pool_allocfree_free(pool, block->block);
+       }
        i_assert(apool->total_alloc_used == 0 && apool->total_alloc_count == 0);
 }