]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: lua: check buffers before initializing socket
authorThierry FOURNIER <tfournier@exceliance.fr>
Mon, 9 Mar 2015 16:07:10 +0000 (17:07 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 9 Mar 2015 17:46:48 +0000 (18:46 +0100)
When a socket is initilized in the body context, a segfaut is generated
because the memory pools are not initilized. This atch check if these
memory pool are initialized.

src/hlua.c

index 3f9b90911b59fba43ecc1a1b85aba90f6d86ca9d..8ddc0b664dd9445df0bb07997dbbfe13ea1ebc94 100644 (file)
@@ -1731,6 +1731,12 @@ __LJMP static int hlua_socket_new(lua_State *L)
        socket = MAY_LJMP(lua_newuserdata(L, sizeof(*socket)));
        memset(socket, 0, sizeof(*socket));
 
+       /* Check if the various memory pools are intialized. */
+       if (!pool2_session || !pool2_channel || !pool2_buffer) {
+               hlua_pusherror(L, "socket: uninitialized pools.");
+               goto out_fail_conf;
+       }
+
        /* Pop a class session metatable and affect it to the userdata. */
        lua_rawgeti(L, LUA_REGISTRYINDEX, class_socket_ref);
        lua_setmetatable(L, -2);