Skip to content
Open
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
11 changes: 10 additions & 1 deletion extensions/window/libwindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,16 @@ static int window_application(lua_State* L) {
[skin checkArgs:LS_TUSERDATA, USERDATA_TAG, LS_TBREAK];
HSwindow *win = [skin toNSObjectAtIndex:1];
HSapplication *app = [[HSapplication alloc] initWithPid:win.pid withState:L];
[skin pushNSObject:app];
// Ensure return value is the only item on the stack to avoid leaking the receiver in coroutines
lua_settop(L, 0);
// When app is nil (process terminated), push nil directly to the caller's L
// instead of going through pushNSObject which may push to a different lua_State
// if the shared LuaSkin instance's L has been temporarily swapped by class-level logging
if (!app) {
lua_pushnil(L);
} else {
[skin pushNSObject:app];
}
return 1;
}

Expand Down