From: Vsevolod Stakhov Date: Thu, 29 Jan 2026 15:19:46 +0000 (+0000) Subject: Revert "[Fix] lua_redis: add defensive check in GC handler" X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c7e6f0ec4545f4fd94adf0c4eea33e02ad6f5583;p=thirdparty%2Frspamd.git Revert "[Fix] lua_redis: add defensive check in GC handler" This reverts commit e753e063c2102d920b8b2ea15f675de04b1aaa99. --- diff --git a/src/lua/lua_redis.c b/src/lua/lua_redis.c index b1c29f9391..214f6433ed 100644 --- a/src/lua/lua_redis.c +++ b/src/lua/lua_redis.c @@ -246,24 +246,10 @@ lua_redis_dtor(struct lua_redis_ctx *ctx) static int lua_redis_gc(lua_State *L) { - void *ud = rspamd_lua_check_udata(L, 1, rspamd_redis_classname); - - if (ud) { - struct lua_redis_ctx **pctx = (struct lua_redis_ctx **) ud; - struct lua_redis_ctx *ctx = *pctx; - - /* - * Defensive check: verify the context appears valid before releasing. - * The context might be freed by another code path while this userdata - * still holds a pointer to it. Check that the destructor matches and - * refcount is reasonable to detect garbage/freed memory. - */ - if (ctx && ctx->ref.dtor == (ref_dtor_cb_t) lua_redis_dtor && - ctx->ref.refcount > 0 && ctx->ref.refcount < 10000) { - REDIS_RELEASE(ctx); - } + struct lua_redis_ctx *ctx = lua_check_redis(L, 1); - *pctx = NULL; + if (ctx) { + REDIS_RELEASE(ctx); } return 0;