fix: lua setInterval stack overflow
This commit is contained in:
@@ -22,6 +22,7 @@ static void remove_lib_funcs(lua::State* L, const char* libname, const char* fun
|
||||
setfield(L, funcs[i], -2);
|
||||
}
|
||||
}
|
||||
pop(L);
|
||||
}
|
||||
|
||||
static void create_libs(lua::State* L) {
|
||||
@@ -44,6 +45,7 @@ static void create_libs(lua::State* L) {
|
||||
addfunc(L, "print", lua::wrap<l_print>);
|
||||
}
|
||||
|
||||
#include <iostream>
|
||||
void lua::initialize() {
|
||||
logger.info() << LUA_VERSION;
|
||||
logger.info() << LUAJIT_VERSION;
|
||||
@@ -54,15 +56,14 @@ void lua::initialize() {
|
||||
}
|
||||
main_thread = L;
|
||||
// Allowed standard libraries
|
||||
luaopen_base(L);
|
||||
luaopen_math(L);
|
||||
luaopen_string(L);
|
||||
luaopen_table(L);
|
||||
luaopen_debug(L);
|
||||
luaopen_jit(L);
|
||||
luaopen_bit(L);
|
||||
|
||||
luaopen_os(L);
|
||||
pop(L, luaopen_base(L));
|
||||
pop(L, luaopen_math(L));
|
||||
pop(L, luaopen_string(L));
|
||||
pop(L, luaopen_table(L));
|
||||
pop(L, luaopen_debug(L));
|
||||
pop(L, luaopen_jit(L));
|
||||
pop(L, luaopen_bit(L));
|
||||
pop(L, luaopen_os(L));
|
||||
const char* removed_os[] {
|
||||
"execute",
|
||||
"exit",
|
||||
|
||||
@@ -145,7 +145,7 @@ void lua::dump_stack(State* L) {
|
||||
}
|
||||
}
|
||||
|
||||
static std::shared_ptr<std::string> createLambdaHandler(State* L) {
|
||||
static std::shared_ptr<std::string> create_lambda_handler(State* L) {
|
||||
auto ptr = reinterpret_cast<ptrdiff_t>(topointer(L, -1));
|
||||
auto name = util::mangleid(ptr);
|
||||
getglobal(L, LAMBDAS_TABLE);
|
||||
@@ -163,16 +163,17 @@ static std::shared_ptr<std::string> createLambdaHandler(State* L) {
|
||||
}
|
||||
|
||||
runnable lua::create_runnable(State* L) {
|
||||
auto funcptr = createLambdaHandler(L);
|
||||
auto funcptr = create_lambda_handler(L);
|
||||
return [=]() {
|
||||
getglobal(L, LAMBDAS_TABLE);
|
||||
getfield(L, *funcptr);
|
||||
call_nothrow(L, 0);
|
||||
pop(L);
|
||||
};
|
||||
}
|
||||
|
||||
scripting::common_func lua::create_lambda(State* L) {
|
||||
auto funcptr = createLambdaHandler(L);
|
||||
auto funcptr = create_lambda_handler(L);
|
||||
return [=](const std::vector<dynamic::Value>& args) {
|
||||
getglobal(L, LAMBDAS_TABLE);
|
||||
getfield(L, *funcptr);
|
||||
|
||||
Reference in New Issue
Block a user