diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-04-11 13:51:08 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-04-11 13:51:08 +0100 |
commit | 38bced7829e676d43264ab1162034a6c3ad3f91d (patch) | |
tree | 17b399a1bbf27392ea692264557354e827e62cbc /src/libutil/hash.c | |
parent | e332d676926f23417c1efccdca72470de6008a46 (diff) | |
download | rspamd-38bced7829e676d43264ab1162034a6c3ad3f91d.tar.gz rspamd-38bced7829e676d43264ab1162034a6c3ad3f91d.zip |
[Fix] Add more guards for heap
Diffstat (limited to 'src/libutil/hash.c')
-rw-r--r-- | src/libutil/hash.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libutil/hash.c b/src/libutil/hash.c index 30ecdd85b..ddf916c20 100644 --- a/src/libutil/hash.c +++ b/src/libutil/hash.c @@ -146,7 +146,9 @@ rspamd_lru_hash_insert (rspamd_lru_hash_t *hash, gpointer key, gpointer value, guint i; res = g_hash_table_lookup (hash->tbl, key); + if (res != NULL) { + rspamd_min_heap_remove_elt (hash->heap, &res->helt); g_hash_table_remove (hash->tbl, key); } else { @@ -155,7 +157,13 @@ rspamd_lru_hash_insert (rspamd_lru_hash_t *hash, gpointer key, gpointer value, for (i = 0; i < MIN (hash->maxsize, expire_aggressive_count); i ++) { res = (rspamd_lru_element_t *)rspamd_min_heap_pop (hash->heap); - g_hash_table_remove (hash->tbl, res->key); + + if (res) { + g_hash_table_remove (hash->tbl, res->key); + } + else { + break; + } } } } |