In init_fuzzy(), two khash tables were created but their destructors
were not added to the config mempool:
- ctx->default_forbidden_ids
- ctx->weak_ids
While these tables were destroyed in the worker cleanup code (before
exit), this cleanup doesn't run during configtest, causing a memory leak.
Fix: Add mempool destructors for both hash tables, similar to how
ctx->keys and ctx->errors_ips are handled. This ensures proper cleanup
in all scenarios including configtest.
ctx->delay = NAN;
ctx->tcp_timeout = DEFAULT_TCP_TIMEOUT;
ctx->default_forbidden_ids = kh_init(fuzzy_key_ids_set);
+ rspamd_mempool_add_destructor(cfg->cfg_pool,
+ (rspamd_mempool_destruct_t) kh_destroy_fuzzy_key_ids_set,
+ ctx->default_forbidden_ids);
ctx->weak_ids = kh_init(fuzzy_key_ids_set);
+ rspamd_mempool_add_destructor(cfg->cfg_pool,
+ (rspamd_mempool_destruct_t) kh_destroy_fuzzy_key_ids_set,
+ ctx->weak_ids);
rspamd_rcl_register_worker_option(cfg,
type,