From 0aa030db022c57947afbae3b97038a403973e3cd Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Fri, 14 Mar 2025 14:49:22 +0100 Subject: Fix crash when using { name = 'auto' } with a lane generated from a string --- src/lanes.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/lanes.cpp b/src/lanes.cpp index 15e04a3..b54f221 100644 --- a/src/lanes.cpp +++ b/src/lanes.cpp @@ -361,10 +361,17 @@ LUAG_FUNC(lane_new) if (!_debugName.empty()) { if (_debugName == "auto") { - lua_Debug _ar; - lua_pushvalue(L, kFuncIdx); // L: ... lane func - lua_getinfo(L, ">S", &_ar); // L: ... lane - luaG_pushstring(L, "%s:%d", _ar.short_src, _ar.linedefined); // L: ... lane "" + if (luaG_type(L, kFuncIdx) == LuaType::STRING) { + lua_Debug _ar; + lua_getstack(L, 2, &_ar); // 0 is here, 1 is lanes.gen, 2 is its caller + lua_getinfo(L, "Sl", &_ar); + luaG_pushstring(L, "%s:%d", _ar.short_src, _ar.currentline); // L: ... lane "" + } else { + lua_Debug _ar; + lua_pushvalue(L, kFuncIdx); // L: ... lane func + lua_getinfo(L, ">S", &_ar); // L: ... lane + luaG_pushstring(L, "%s:%d", _ar.short_src, _ar.linedefined); // L: ... lane "" + } lua_replace(L, _name_idx); // L: ... lane _debugName = luaG_tostring(L, _name_idx); } -- cgit v1.2.3-55-g6feb