Skip to content

Commit 88fbe7c

Browse files
committedMar 7, 2016
Use LuaErrors in security check macros
Throwing a LuaError calls destructors as it propagates up the stack, wheres lua_error just executes a longjmp.
1 parent 04e311a commit 88fbe7c

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed
 

Diff for: ‎src/script/cpp_api/s_security.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2525

2626
#define CHECK_SECURE_PATH(L, path) \
2727
if (!ScriptApiSecurity::checkPath(L, path)) { \
28-
lua_pushstring(L, (std::string("Attempt to access external file ") + \
29-
path + " with mod security on.").c_str()); \
30-
lua_error(L); \
28+
throw LuaError(std::string("Attempt to access external file ") + \
29+
path + " with mod security on."); \
3130
}
3231
#define CHECK_SECURE_PATH_OPTIONAL(L, path) \
3332
if (ScriptApiSecurity::isSecure(L)) { \

Diff for: ‎src/script/lua_api/l_util.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ int ModApiUtil::l_get_us_time(lua_State *L)
7777
#define CHECK_SECURE_SETTING(L, name) \
7878
if (ScriptApiSecurity::isSecure(L) && \
7979
name.compare(0, 7, "secure.") == 0) { \
80-
lua_pushliteral(L, "Attempt to set secure setting."); \
81-
lua_error(L); \
80+
throw LuaError("Attempt to set secure setting."); \
8281
}
8382

8483
// setting_set(name, value)

0 commit comments

Comments
 (0)