From fb324d18aa9956f7e14ee80cf78d71359c28bf50 Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Thu, 24 Apr 2025 22:30:20 +0100 Subject: [PATCH] Fix crash when `require` is called from root VM stack --- Require/Runtime/src/RequireImpl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Require/Runtime/src/RequireImpl.cpp b/Require/Runtime/src/RequireImpl.cpp index 1858abcb..4f8a3f26 100644 --- a/Require/Runtime/src/RequireImpl.cpp +++ b/Require/Runtime/src/RequireImpl.cpp @@ -43,7 +43,8 @@ static bool isCached(lua_State* L, const std::string& key) static ResolvedRequire resolveRequire(luarequire_Configuration* lrc, lua_State* L, void* ctx, std::string path) { lua_Debug ar; - lua_getinfo(L, 1, "s", &ar); + if (!lua_getinfo(L, 1, "s", &ar)) + luaL_error(L, "require is not supported in this context"); if (!lrc->is_require_allowed(L, ctx, ar.source)) luaL_error(L, "require is not supported in this context");