cosmopolitan/tool/net/luacheck.h
Paul Kulchenko 233144b19d
Fix memory deallocation while yielding in redbean. (#384)
The yielded coroutine was removed from the stack too early,
leaving it not being anchored, which led to memory freed prematurely.
2022-04-14 18:13:53 -07:00

21 lines
758 B
C

#ifndef COSMOPOLITAN_TOOL_NET_LUACHECK_H_
#define COSMOPOLITAN_TOOL_NET_LUACHECK_H_
#include "libc/log/log.h"
#include "libc/mem/mem.h"
#include "third_party/lua/cosmo.h"
#include "third_party/lua/lua.h"
#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); \
} \
} while (0)
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_TOOL_NET_LUACHECK_H_ */