Message ID | 20171010083752.7491-1-christian.storm@siemens.com |
---|---|
State | Accepted |
Headers | show |
Series | Lua: don't overfree stack in l_register_handler() | expand |
On 10/10/2017 10:37, Christian Storm wrote: > luaL_ref() pops from the stack, hence lua_pop() has > to clean only one stack item. > > Signed-off-by: Christian Storm <christian.storm@siemens.com> > --- > corelib/lua_interface.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c > index 14f9251..15eae98 100644 > --- a/corelib/lua_interface.c > +++ b/corelib/lua_interface.c > @@ -478,8 +478,8 @@ static int l_register_handler( lua_State *L ) { > const char *handler_desc = luaL_checkstring(L, 1); > /* store the callback function in registry */ > *l_func_ref = luaL_ref (L, LUA_REGISTRYINDEX); > - /* pop the arguments from the stack */ > - lua_pop (L, 2); > + /* cleanup stack */ > + lua_pop (L, 1); > register_handler(handler_desc, l_handler_wrapper, > ANY_HANDLER, l_func_ref); > return 0; > Applied to -master, thanks ! Best regards, Stefano Babic
diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c index 14f9251..15eae98 100644 --- a/corelib/lua_interface.c +++ b/corelib/lua_interface.c @@ -478,8 +478,8 @@ static int l_register_handler( lua_State *L ) { const char *handler_desc = luaL_checkstring(L, 1); /* store the callback function in registry */ *l_func_ref = luaL_ref (L, LUA_REGISTRYINDEX); - /* pop the arguments from the stack */ - lua_pop (L, 2); + /* cleanup stack */ + lua_pop (L, 1); register_handler(handler_desc, l_handler_wrapper, ANY_HANDLER, l_func_ref); return 0;
luaL_ref() pops from the stack, hence lua_pop() has to clean only one stack item. Signed-off-by: Christian Storm <christian.storm@siemens.com> --- corelib/lua_interface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)