Skip to content

Commit

Permalink
feat: avoid crashes on getcallingscript by try catching it and pushin…
Browse files Browse the repository at this point in the history
…g nil. The thread should have the script as a global, anyways.
  • Loading branch information
SecondNewtonLaw committed Sep 3, 2024
1 parent 13d8cc3 commit 0ea22ea
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions Environment/Libraries/Closures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ namespace RbxStu {
}

int getcallingscript(lua_State *L) {
auto base = clvalue(L->base_ci->func);
L->top->tt = lua_Type::LUA_TTABLE;
L->top->value.p = base->env;
L->top++;
try {
lua_getglobal(L, "script");
} catch (...) {
lua_pushnil(L);
}

lua_getfield(L, -1, "script");
lua_remove(L, -2);
return 1;
}

Expand Down

0 comments on commit 0ea22ea

Please sign in to comment.