From: Vsevolod Stakhov Date: Tue, 23 Feb 2016 16:24:07 +0000 (+0000) Subject: Try to workaround for double free in redis X-Git-Tag: 1.2.0~181 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b5db340819fe22f58827c6c7810b18f317dd8449;p=rspamd.git Try to workaround for double free in redis --- diff --git a/src/lua/lua_redis.c b/src/lua/lua_redis.c index dcb1af45a..4ef563782 100644 --- a/src/lua/lua_redis.c +++ b/src/lua/lua_redis.c @@ -130,7 +130,14 @@ lua_redis_dtor (struct lua_redis_ctx *ctx) if (ud->ctx) { ud->terminated = 1; + /* + * On calling of redisFree, hiredis calls for callbacks pending + * Hence, to avoid double free, we ensure that the object must + * still be alive here! + */ + ctx->ref.refcount = 100500; redisAsyncFree (ud->ctx); + ctx->ref.refcount = 0; lua_redis_free_args (ud->args, ud->nargs); event_del (&ud->timeout); luaL_unref (ud->L, LUA_REGISTRYINDEX, ud->cbref);