From b5db340819fe22f58827c6c7810b18f317dd8449 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 23 Feb 2016 16:24:07 +0000 Subject: [PATCH] Try to workaround for double free in redis --- src/lua/lua_redis.c | 7 +++++++ 1 file changed, 7 insertions(+) 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); -- 2.39.5