From: Vsevolod Stakhov Date: Wed, 29 Oct 2025 12:34:57 +0000 (+0000) Subject: [Minor] One more leak fix X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=97e180f8be125278448c3bb0d6b83323241f566f;p=thirdparty%2Frspamd.git [Minor] One more leak fix --- diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c index 1f8cccef24..656e13a457 100644 --- a/src/fuzzy_storage.c +++ b/src/fuzzy_storage.c @@ -493,7 +493,8 @@ ucl_keymap_dtor_cb(struct map_cb_data *data) kh_foreach_value(jb->ctx->dynamic_keys, key, { REF_RELEASE(key); }); - kh_destroy(rspamd_fuzzy_keys_hash, jb->ctx->dynamic_keys); + /* Clear hash content but don't destroy - mempool destructor will handle it */ + kh_clear(rspamd_fuzzy_keys_hash, jb->ctx->dynamic_keys); g_free(jb); } @@ -812,6 +813,10 @@ fuzzy_key_dtor(gpointer p) struct fuzzy_key *key = p; if (key) { + if (key->key) { + rspamd_keypair_unref(key->key); + } + if (key->stat) { REF_RELEASE(key->stat); } @@ -3565,6 +3570,7 @@ fuzzy_add_keypair_from_ucl(struct rspamd_config *cfg, const ucl_object_t *obj, } if (rspamd_keypair_type(kp) != RSPAMD_KEYPAIR_KEX) { + rspamd_keypair_unref(kp); return FALSE; } @@ -4308,6 +4314,9 @@ start_fuzzy(struct rspamd_worker *worker) struct fuzzy_keymap_ucl_buf *jb, **pjb; ctx->dynamic_keys = kh_init(rspamd_fuzzy_keys_hash); + rspamd_mempool_add_destructor(ctx->cfg->cfg_pool, + (rspamd_mempool_destruct_t) fuzzy_hash_table_dtor, + ctx->dynamic_keys); /* Now try to add map with ucl data */ jb = g_malloc(sizeof(struct fuzzy_keymap_ucl_buf)); pjb = g_malloc(sizeof(struct fuzzy_keymap_ucl_buf *));