]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: lua: memory leak
authorThierry FOURNIER <thierry.fournier@ozon.io>
Wed, 26 Apr 2017 12:25:58 +0000 (14:25 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 26 Apr 2017 13:13:18 +0000 (15:13 +0200)
The priv context is not cleaned when we set a new priv context.
This is caused by a stupid swap between two parameter of the
luaL_unref() function.

workaround: use set_priv only once when we process a stream.

This patch should be backported in version 1.7 and 1.6

src/hlua.c

index 77e5a9d5cf6b5ce5b4e0fa714c2142acf3a3da8c..6ce18e1ca71528017e6c5b0c941f8042cd0faa46 100644 (file)
@@ -3310,7 +3310,7 @@ __LJMP static int hlua_applet_tcp_set_priv(lua_State *L)
 
        /* Remove previous value. */
        if (hlua->Mref != -1)
-               luaL_unref(L, hlua->Mref, LUA_REGISTRYINDEX);
+               luaL_unref(L, LUA_REGISTRYINDEX, hlua->Mref);
 
        /* Get and store new value. */
        lua_pushvalue(L, 2); /* Copy the element 2 at the top of the stack. */
@@ -3773,7 +3773,7 @@ __LJMP static int hlua_applet_http_set_priv(lua_State *L)
 
        /* Remove previous value. */
        if (hlua->Mref != -1)
-               luaL_unref(L, hlua->Mref, LUA_REGISTRYINDEX);
+               luaL_unref(L, LUA_REGISTRYINDEX, hlua->Mref);
 
        /* Get and store new value. */
        lua_pushvalue(L, 2); /* Copy the element 2 at the top of the stack. */
@@ -4860,7 +4860,7 @@ __LJMP static int hlua_set_priv(lua_State *L)
 
        /* Remove previous value. */
        if (hlua->Mref != -1)
-               luaL_unref(L, hlua->Mref, LUA_REGISTRYINDEX);
+               luaL_unref(L, LUA_REGISTRYINDEX, hlua->Mref);
 
        /* Get and store new value. */
        lua_pushvalue(L, 2); /* Copy the element 2 at the top of the stack. */