Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

luv_cfpcall: Fix stack balancing after an uncaught error #736

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/luv.c
Original file line number Diff line number Diff line change
Expand Up @@ -715,9 +715,11 @@ LUALIB_API int luv_cfpcall(lua_State* L, int nargs, int nresult, int flags) {
case LUA_OK:
break;
case LUA_ERRMEM:
if ((flags & LUVF_CALLBACK_NOERRMSG) == 0)
if ((flags & LUVF_CALLBACK_NOERRMSG) == 0) {
fprintf(stderr, "System Error: %s\n",
luaL_tolstring(L, lua_absindex(L, -1), NULL));
lua_pop(L, 1); // Remove error string pushed by luaL_tolstring()
}
if ((flags & LUVF_CALLBACK_NOEXIT) == 0)
exit(-1);
lua_pop(L, 1);
Expand All @@ -726,9 +728,11 @@ LUALIB_API int luv_cfpcall(lua_State* L, int nargs, int nresult, int flags) {
case LUA_ERRRUN:
case LUA_ERRERR:
default:
if ((flags & LUVF_CALLBACK_NOERRMSG) == 0)
if ((flags & LUVF_CALLBACK_NOERRMSG) == 0) {
fprintf(stderr, "Uncaught Error: %s\n",
luaL_tolstring(L, lua_absindex(L, -1), NULL));
lua_pop(L, 1); // Remove error string pushed by luaL_tolstring()
}
if ((flags & LUVF_CALLBACK_NOEXIT) == 0)
exit(-1);
lua_pop(L, 1);
mwild1 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading