From 2739154eaa04877b0d19d1dfc56fc1679aa6bb98 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 19 Jun 2024 08:56:51 -0400 Subject: Try harder to keep Luau's lua_getinfo() from crashing. --- indra/llcommon/lua_function.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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; } -- cgit v1.2.3