Commit d2c75412 authored by Chen Bill's avatar Chen Bill Committed by GitHub

remove unsafe functions by default (#741)

parent e7995cbe
...@@ -32,6 +32,15 @@ interpreter::interpreter(duel* pd): coroutines(256) { ...@@ -32,6 +32,15 @@ interpreter::interpreter(duel* pd): coroutines(256) {
lua_pop(lua_state, 1); lua_pop(lua_state, 1);
luaL_requiref(lua_state, "math", luaopen_math, 1); luaL_requiref(lua_state, "math", luaopen_math, 1);
lua_pop(lua_state, 1); lua_pop(lua_state, 1);
auto nil_out = [&](const char* name) {
lua_pushnil(lua_state);
lua_setglobal(lua_state, name);
};
nil_out("collectgarbage");
#ifndef ENABLE_UNSAFE_LIBRARIES
nil_out("dofile");
nil_out("loadfile");
#endif // ENABLE_UNSAFE_LIBRARIES
//open all libs //open all libs
scriptlib::open_cardlib(lua_state); scriptlib::open_cardlib(lua_state);
scriptlib::open_effectlib(lua_state); scriptlib::open_effectlib(lua_state);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment