]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: lua: bad memory access
authorThierry FOURNIER <thierry.fournier@ozon.io>
Sun, 16 Jul 2017 22:44:40 +0000 (00:44 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 18 Jul 2017 04:41:38 +0000 (06:41 +0200)
We cannot perform garbage collection on unreferenced thread.
This memory is now free and another Lua process can use it for
other things.

HAProxy is monothread, so this bug doesn't cause crash.

This patch must be backported in 1.6 and 1.7

src/hlua.c

index ef172fb68d997827bd30f8eee73b4f1596914948..71812a6de123d64b39f2016b34dd5077371562a3 100644 (file)
@@ -901,16 +901,10 @@ void hlua_ctx_destroy(struct hlua *lua)
         * the garbage collection.
         */
        if (lua->flags & HLUA_MUST_GC) {
-               if (!SET_SAFE_LJMP(lua->T))
+               if (!SET_SAFE_LJMP(gL.T))
                        return;
-               lua_gc(lua->T, LUA_GCCOLLECT, 0);
-               RESET_SAFE_LJMP(lua->T);
-               if (lua_status(lua->T) != LUA_OK) {
-                       if (!SET_SAFE_LJMP(gL.T))
-                               return;
-                       lua_gc(gL.T, LUA_GCCOLLECT, 0);
-                       RESET_SAFE_LJMP(gL.T);
-               }
+               lua_gc(gL.T, LUA_GCCOLLECT, 0);
+               RESET_SAFE_LJMP(gL.T);
        }
 
        lua->T = NULL;