diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-06-19 08:56:51 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-06-19 08:56:51 -0400 |
commit | 2739154eaa04877b0d19d1dfc56fc1679aa6bb98 (patch) | |
tree | 3dbd123b453cbb52706207e49123c05d95743e05 | |
parent | 72af1de39cee5d5e2cd3d6a45a7421e938027976 (diff) |
Try harder to keep Luau's lua_getinfo() from crashing.
-rw-r--r-- | indra/llcommon/lua_function.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/indra/llcommon/lua_function.cpp b/indra/llcommon/lua_function.cpp index 7e99480201..e76bd55dbb 100644 --- a/indra/llcommon/lua_function.cpp +++ b/indra/llcommon/lua_function.cpp @@ -78,8 +78,13 @@ fsyspath lluau::source_path(lua_State* L) // In particular: // passing level=1 gets you info about the deepest function call // passing level=lua_stackdepth() gets you info about the topmost script + // Empirically, lua_getinfo(level > 1) behaves strangely (including + // crashing the program) unless you iterate from 1 to desired level. lua_Debug ar{}; - lua_getinfo(L, lua_stackdepth(L), "s", &ar); + for (int i(0), depth(lua_stackdepth(L)); i <= depth; ++i) + { + lua_getinfo(L, i, "s", &ar); + } return ar.source; } |