]> source.dussan.org Git - rspamd.git/commitdiff
Try to workaround for double free in redis
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 23 Feb 2016 16:24:07 +0000 (16:24 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 23 Feb 2016 16:24:07 +0000 (16:24 +0000)
src/lua/lua_redis.c

index dcb1af45a233876df14ca2b9f14302ed1beda4e5..4ef5637825fe790b9a9d44376f7f9f8116867673 100644 (file)
@@ -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);