From a2623225c1ad0230ea65af99f08eed8cfee559fb Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 12 Aug 2009 18:57:56 +0200 Subject: [PATCH] lualib: fix error function removal Signed-off-by: Julien Danjou --- common/lualib.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/lualib.h b/common/lualib.h index f11e8a371..4f8141a76 100644 --- a/common/lualib.h +++ b/common/lualib.h @@ -107,6 +107,7 @@ luaA_dofunction(lua_State *L, int nargs, int nret) lua_pushcfunction(L, luaA_dofunction_error); /* Move error handling function before args and function */ lua_insert(L, - nargs - 2); + int error_func_pos = lua_gettop(L) - nargs - 2; if(lua_pcall(L, nargs, nret, - nargs - 2)) { warn("%s", lua_tostring(L, -1)); @@ -115,7 +116,7 @@ luaA_dofunction(lua_State *L, int nargs, int nret) return false; } /* Remove error function */ - lua_remove(L, - nret - 1); + lua_remove(L, error_func_pos); return true; }