From 00384adf7bf05591a4dbe97fa6ea1df52c538833 Mon Sep 17 00:00:00 2001 From: Allanis Date: Sat, 17 May 2014 14:25:55 +0100 Subject: [PATCH] [Fix] More Lua stack balancing. --- src/llua_faction.c | 2 ++ src/llua_misn.c | 3 ++- src/llua_space.c | 9 +++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/llua_faction.c b/src/llua_faction.c index ad0b1b9..17da547 100644 --- a/src/llua_faction.c +++ b/src/llua_faction.c @@ -88,6 +88,8 @@ static int factionL_createmetatable(lua_State* L, int readonly) { /* Register the values. */ luaL_register(L, NULL, (readonly) ? faction_methods_cond : faction_methods); + lua_pop(L, 1); + return 0; /* No error. */ } diff --git a/src/llua_misn.c b/src/llua_misn.c index d001974..9d58ce5 100644 --- a/src/llua_misn.c +++ b/src/llua_misn.c @@ -290,7 +290,8 @@ static int misn_runTopStack(Mission* misn, char* func) { cur_mission = misn; misn_delete = 0; - if((ret = lua_pcall(misn->L, 0, 0, 0))) { + ret = lua_pcall(misn->L, 0, 0, 0); + if(ret != 0) { /* Error has occured. */ /* Did an oops. */ err = (lua_isstring(misn->L, -1)) ? (char*) lua_tostring(misn->L, -1) : NULL; if(strcmp(err, "Mission Done")!=0) diff --git a/src/llua_space.c b/src/llua_space.c index e9c823b..545aa15 100644 --- a/src/llua_space.c +++ b/src/llua_space.c @@ -124,6 +124,9 @@ static int planetL_createmetatable(lua_State* L) { /* Register the values. */ luaL_register(L, NULL, planet_methods); + /* Clean up. */ + lua_pop(L, 1); + return 0; /* No error. */ } @@ -143,6 +146,9 @@ static int systemL_createmetatable(lua_State* L) { /* Register the values. */ luaL_register(L, NULL, system_methods); + /* Clean up. */ + lua_pop(L, 1); + return 0; /* No error. */ } @@ -162,6 +168,9 @@ static int vectorL_createmetatable(lua_State* L) { /* Register the values. */ luaL_register(L, NULL, vector_methods); + /* Clean up. */ + lua_pop(L, 1); + return 0; /* No error. */ }