aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2016-03-06 14:41:26 -0500
committerShadowNinja <shadowninja@minetest.net>2016-03-07 13:37:15 -0500
commit88fbe7ca1e5451851ee0c7ab5524c39a7bb703c2 (patch)
tree53cf5103ba59dab58fd03732472be87a44c4a78a /src
parent04e311a36d15ad6c1e4436f169fe6b45e855009f (diff)
downloadminetest-88fbe7ca1e5451851ee0c7ab5524c39a7bb703c2.tar.gz
minetest-88fbe7ca1e5451851ee0c7ab5524c39a7bb703c2.tar.bz2
minetest-88fbe7ca1e5451851ee0c7ab5524c39a7bb703c2.zip
Use LuaErrors in security check macros
Throwing a LuaError calls destructors as it propagates up the stack, wheres lua_error just executes a longjmp.
Diffstat (limited to 'src')
-rw-r--r--src/script/cpp_api/s_security.h5
-rw-r--r--src/script/lua_api/l_util.cpp3
2 files changed, 3 insertions, 5 deletions
diff --git a/src/script/cpp_api/s_security.h b/src/script/cpp_api/s_security.h
index 4a4389cf5..97bc5c067 100644
--- a/src/script/cpp_api/s_security.h
+++ b/src/script/cpp_api/s_security.h
@@ -25,9 +25,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define CHECK_SECURE_PATH(L, path) \
if (!ScriptApiSecurity::checkPath(L, path)) { \
- lua_pushstring(L, (std::string("Attempt to access external file ") + \
- path + " with mod security on.").c_str()); \
- lua_error(L); \
+ throw LuaError(std::string("Attempt to access external file ") + \
+ path + " with mod security on."); \
}
#define CHECK_SECURE_PATH_OPTIONAL(L, path) \
if (ScriptApiSecurity::isSecure(L)) { \
diff --git a/src/script/lua_api/l_util.cpp b/src/script/lua_api/l_util.cpp
index df46925d1..98f70d917 100644
--- a/src/script/lua_api/l_util.cpp
+++ b/src/script/lua_api/l_util.cpp
@@ -77,8 +77,7 @@ int ModApiUtil::l_get_us_time(lua_State *L)
#define CHECK_SECURE_SETTING(L, name) \
if (ScriptApiSecurity::isSecure(L) && \
name.compare(0, 7, "secure.") == 0) { \
- lua_pushliteral(L, "Attempt to set secure setting."); \
- lua_error(L); \
+ throw LuaError("Attempt to set secure setting."); \
}
// setting_set(name, value)