Skip to content

Commit

Permalink
Fix testrunner warnings (surge-synthesizer#7745)
Browse files Browse the repository at this point in the history
  • Loading branch information
nuoun authored Aug 11, 2024
1 parent f3cefbe commit 6c59e38
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/common/LuaSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ int lua_limitRange(lua_State *L)
return 1;
}

// customized print that outputs limted amount of arguments and restricts use to strings and numbers
// custom print that outputs limited amount of arguments and restricts use to strings and numbers
int lua_sandboxPrint(lua_State *L)
{
#if HAS_LUA
Expand Down Expand Up @@ -174,10 +174,16 @@ bool Surge::LuaSupport::setSurgeFunctionEnvironment(lua_State *L)
lua_pushcfunction(L, lua_sandboxPrint);
lua_setfield(L, eidx, "print");

// add global tables
lua_getglobal(L, "surge");
lua_setfield(L, eidx, "surge");
lua_getglobal(L, "shared");
lua_setfield(L, eidx, "shared");

// add whitelisted functions and modules
std::vector<std::string> sandboxWhitelist = {"pairs", "ipairs", "unpack", "next",
"type", "tostring", "tonumber", "setmetatable",
"error", "surge", "shared"};
std::vector<std::string> sandboxWhitelist = {"pairs", "ipairs", "unpack",
"next", "type", "tostring",
"tonumber", "setmetatable", "error"};
for (const auto &f : sandboxWhitelist)
{
lua_getglobal(L, f.c_str()); // stack: f>t>f
Expand Down

0 comments on commit 6c59e38

Please sign in to comment.