mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-04 18:28:30 +00:00
Reset Lua stack to drop unused returned values (#382)
Since some Lua code may return values that will be left on stack, they need to be removed to avoid growing the stack unnecessarily.
This commit is contained in:
parent
d31bebdd2d
commit
668dc42bac
1 changed files with 2 additions and 1 deletions
|
@ -176,6 +176,7 @@ STATIC_YOINK("zip_uri_support");
|
||||||
char *s = LuaFormatStack(L); \
|
char *s = LuaFormatStack(L); \
|
||||||
WARNF("lua stack should be empty!\n%s", s); \
|
WARNF("lua stack should be empty!\n%s", s); \
|
||||||
free(s); \
|
free(s); \
|
||||||
|
lua_settop(L, 0); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
@ -1065,9 +1066,9 @@ static bool LuaOnClientConnection(void) {
|
||||||
dropit = lua_toboolean(L, -1);
|
dropit = lua_toboolean(L, -1);
|
||||||
} else {
|
} else {
|
||||||
LogLuaError("OnClientConnection", lua_tostring(L, -1));
|
LogLuaError("OnClientConnection", lua_tostring(L, -1));
|
||||||
lua_pop(L, 1); // pop error
|
|
||||||
dropit = false;
|
dropit = false;
|
||||||
}
|
}
|
||||||
|
lua_pop(L, 1); // pop result or error
|
||||||
AssertLuaStackIsEmpty(L);
|
AssertLuaStackIsEmpty(L);
|
||||||
return dropit;
|
return dropit;
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue