diff options
author | sfan5 <sfan5@live.de> | 2022-05-02 20:55:04 +0200 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2022-05-02 20:56:06 +0200 |
commit | e7659883cc6fca343785da2a1af3890ae273abbf (patch) | |
tree | b8d2e3bdbe10ed0e99074207113e24ccca3fb5df /src/script/common/c_internal.cpp | |
parent | 663c9364289dae45aeb86a87cba826f577d84a9c (diff) | |
download | minetest-e7659883cc6fca343785da2a1af3890ae273abbf.tar.gz minetest-e7659883cc6fca343785da2a1af3890ae273abbf.tar.bz2 minetest-e7659883cc6fca343785da2a1af3890ae273abbf.zip |
Async environment for mods to do concurrent tasks (#11131)
Diffstat (limited to 'src/script/common/c_internal.cpp')
-rw-r--r-- | src/script/common/c_internal.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/script/common/c_internal.cpp b/src/script/common/c_internal.cpp index df82dba14..ddd2d184c 100644 --- a/src/script/common/c_internal.cpp +++ b/src/script/common/c_internal.cpp @@ -166,3 +166,17 @@ void log_deprecated(lua_State *L, std::string message, int stack_depth) infostream << script_get_backtrace(L) << std::endl; } +void call_string_dump(lua_State *L, int idx) +{ + // Retrieve string.dump from insecure env to avoid it being tampered with + lua_rawgeti(L, LUA_REGISTRYINDEX, CUSTOM_RIDX_GLOBALS_BACKUP); + if (!lua_isnil(L, -1)) + lua_getfield(L, -1, "string"); + else + lua_getglobal(L, "string"); + lua_getfield(L, -1, "dump"); + lua_remove(L, -2); // remove _G + lua_remove(L, -2); // remove 'string' table + lua_pushvalue(L, idx); + lua_call(L, 1, 1); +} |