summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-06-19 08:56:51 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-06-19 08:56:51 -0400
commit2739154eaa04877b0d19d1dfc56fc1679aa6bb98 (patch)
tree3dbd123b453cbb52706207e49123c05d95743e05 /indra
parent72af1de39cee5d5e2cd3d6a45a7421e938027976 (diff)
Try harder to keep Luau's lua_getinfo() from crashing.
Diffstat (limited to 'indra')
-rw-r--r--indra/llcommon/lua_function.cpp7
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;
}