Fix reporting of Lua stack items from various hook calls (#395)

Some hooks can be called after OnHttpRequest, which may leave an
anchored item on stack, so this have to be taken into account to
avoid spurious reports.
This commit is contained in:
Paul Kulchenko 2022-04-27 21:57:52 -07:00 committed by GitHub
parent e3a7ab1804
commit 9a6bd304a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 12 deletions

View file

@ -7,13 +7,15 @@
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
#define AssertLuaStackIsEmpty(L) \
do { \
if (lua_gettop(L)) { \
char *s = LuaFormatStack(L); \
WARNF("lua stack should be empty!\n%s", s); \
free(s); \
} \
#define AssertLuaStackIsAt(L, level) \
do { \
if (lua_gettop(L) > level) { \
char *s = LuaFormatStack(L); \
WARNF("lua stack should be at %d;" \
" extra values ignored:\n%s", \
level, s); \
free(s); \
} \
} while (0)
COSMOPOLITAN_C_END_