From 23677be951b4dc2b9cc174ceb92f0e0b8e8eb867 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Tue, 25 Jun 2019 21:18:08 +0200 Subject: Load CSM environment after the restrictions are known Safety-guards for CSM callbacks to abort on a bad implementation Only run callbacks when the mods are loaded (and with it: builtin) Duplication checks inside constructors --- src/script/cpp_api/s_base.cpp | 7 +++++++ src/script/cpp_api/s_security.cpp | 1 + 2 files changed, 8 insertions(+) (limited to 'src/script/cpp_api') diff --git a/src/script/cpp_api/s_base.cpp b/src/script/cpp_api/s_base.cpp index e73f613ce..caa335d76 100644 --- a/src/script/cpp_api/s_base.cpp +++ b/src/script/cpp_api/s_base.cpp @@ -232,6 +232,13 @@ void ScriptApiBase::loadModFromMemory(const std::string &mod_name) void ScriptApiBase::runCallbacksRaw(int nargs, RunCallbacksMode mode, const char *fxn) { +#ifndef SERVER + // Hard fail for bad guarded callbacks + // Only run callbacks when the scripting enviroment is loaded + FATAL_ERROR_IF(m_type == ScriptingType::Client && + !getClient()->modsLoaded(), fxn); +#endif + #ifdef SCRIPTAPI_LOCK_DEBUG assert(m_lock_recursion_count > 0); #endif diff --git a/src/script/cpp_api/s_security.cpp b/src/script/cpp_api/s_security.cpp index 876c7761a..d972be980 100644 --- a/src/script/cpp_api/s_security.cpp +++ b/src/script/cpp_api/s_security.cpp @@ -264,6 +264,7 @@ void ScriptApiSecurity::initializeSecurityClient() }; static const char *debug_whitelist[] = { "getinfo", + "traceback" }; #if USE_LUAJIT -- cgit v1.2.3