summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMnikolenko Productengine <mnikolenko@productengine.com>2024-02-26 23:55:30 +0200
committerMnikolenko Productengine <mnikolenko@productengine.com>2024-02-26 23:55:30 +0200
commit01a94f9d8378bb1094f4272b37ed9b966703f0b6 (patch)
tree86ce11fddeb5fc17453502d489d32a81c8c48f24
parent758378859ce2f5bac2e472f5f6f24061bce7c153 (diff)
Clear the stack after requiring a module
-rw-r--r--indra/newview/llluamanager.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/indra/newview/llluamanager.cpp b/indra/newview/llluamanager.cpp
index 54acb49b00..4463fe65f5 100644
--- a/indra/newview/llluamanager.cpp
+++ b/indra/newview/llluamanager.cpp
@@ -530,8 +530,12 @@ lua_function(require, "require(module_name) : module_name can be fullpath or jus
LLRequireResolver::ResolvedRequire resolvedRequire = LLRequireResolver::resolveRequire(L, name);
- if (resolvedRequire.status == LLRequireResolver::ModuleStatus::Cached)
+ if (resolvedRequire.status == LLRequireResolver::ModuleStatus::Cached)
+ {
+ // remove _MODULES from stack
+ lua_remove(L, -2);
return finishrequire(L);
+ }
else if (resolvedRequire.status == LLRequireResolver::ModuleStatus::NotFound)
luaL_errorL(L, "error requiring module");
@@ -571,6 +575,11 @@ lua_function(require, "require(module_name) : module_name can be fullpath or jus
lua_pushvalue(L, -1);
lua_setfield(L, -4, resolvedRequire.absolutePath.c_str());
- // L stack: _MODULES ML result
+ //remove _MODULES from stack
+ lua_remove(L, -3);
+ // remove ML from stack
+ lua_remove(L, -2);
+
+ // L stack: [module name] [result]
return finishrequire(L);
}