]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix sanity check
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 23 Aug 2017 19:13:25 +0000 (20:13 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 23 Aug 2017 19:13:25 +0000 (20:13 +0100)
src/libutil/mem_pool.c

index 4861a2127856fe2ba1f55217b160d52c76f36599..db7cf298c9f9fa72c90ed454e1682d11f797745c 100644 (file)
@@ -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 +=