From: Vsevolod Stakhov Date: Wed, 23 Aug 2017 19:13:25 +0000 (+0100) Subject: [Minor] Fix sanity check X-Git-Tag: 1.7.0~707 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fcc439c9fd860bc6d03c81889fb5178be2aecc9b;p=rspamd.git [Minor] Fix sanity check --- diff --git a/src/libutil/mem_pool.c b/src/libutil/mem_pool.c index 4861a2127..db7cf298c 100644 --- a/src/libutil/mem_pool.c +++ b/src/libutil/mem_pool.c @@ -645,9 +645,13 @@ rspamd_mempool_delete (rspamd_mempool_t * pool) POOL_MTX_LOCK (); /* Find free space in pool chain */ - cur = pool->pools[RSPAMD_MEMPOOL_NORMAL] != NULL ? - g_ptr_array_index (pool->pools[RSPAMD_MEMPOOL_NORMAL], - pool->pools[RSPAMD_MEMPOOL_NORMAL]->len - 1) : NULL; + cur = NULL; + + if (pool->pools[RSPAMD_MEMPOOL_NORMAL] != NULL && + pool->pools[RSPAMD_MEMPOOL_NORMAL]->len > 0) { + cur = g_ptr_array_index (pool->pools[RSPAMD_MEMPOOL_NORMAL], + pool->pools[RSPAMD_MEMPOOL_NORMAL]->len - 1); + } if (cur) { pool->entry->elts[pool->entry->cur_elts].leftover +=