]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] re_cache: initialize async context to prevent random callback skipping
authorVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 29 Jan 2026 16:35:35 +0000 (16:35 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 29 Jan 2026 16:35:35 +0000 (16:35 +0000)
Use g_malloc0 instead of g_malloc when allocating rspamd_re_cache_async_ctx
to ensure callback_processed flag is initialized to FALSE. Without this,
the flag could randomly be TRUE (from uninitialized memory), causing the
exists/save callbacks to be silently skipped and preventing re_class
compilation from proceeding after cache misses.

src/libserver/re_cache.c

index d4cc43bc26dd5d0310bd93e79830f851251bddd6..a7a3b2c699a6d02696f483e12ba0558bc0827719 100644 (file)
@@ -2410,7 +2410,7 @@ rspamd_re_cache_compile_timer_cb(EV_P_ ev_timer *w, int revents)
 
        if (cbdata->state == RSPAMD_RE_CACHE_COMPILE_STATE_CHECK_EXISTS) {
                /* Check via Lua backend (handles file, redis, http) */
-               struct rspamd_re_cache_async_ctx *ctx = g_malloc(sizeof(*ctx));
+               struct rspamd_re_cache_async_ctx *ctx = g_malloc0(sizeof(*ctx));
                ctx->cbdata = cbdata;
                ctx->loop = loop;
                ctx->w = w;
@@ -2651,7 +2651,7 @@ rspamd_re_cache_compile_timer_cb(EV_P_ ev_timer *w, int revents)
                        offset += iov[j].iov_len;
                }
 
-               struct rspamd_re_cache_async_ctx *ctx = g_malloc(sizeof(*ctx));
+               struct rspamd_re_cache_async_ctx *ctx = g_malloc0(sizeof(*ctx));
                ctx->cbdata = cbdata;
                ctx->loop = loop;
                ctx->w = w;