From 4a6170cce11193f128c041b2a52d1407879ea5bd Mon Sep 17 00:00:00 2001 From: Thierry FOURNIER Date: Mon, 9 Mar 2015 17:07:10 +0100 Subject: [PATCH] BUG/MINOR: lua: check buffers before initializing socket 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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/hlua.c b/src/hlua.c index 3f9b90911..8ddc0b664 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -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);