diff options
Diffstat (limited to 'src/script/common/c_content.cpp')
-rw-r--r-- | src/script/common/c_content.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp index 962391a04..c4acb7c32 100644 --- a/src/script/common/c_content.cpp +++ b/src/script/common/c_content.cpp @@ -1088,8 +1088,11 @@ bool push_json_value(lua_State *L, const Json::Value &value, int nullindex) } // Converts Lua table --> JSON -void read_json_value(lua_State *L, Json::Value &root, int index) +void read_json_value(lua_State *L, Json::Value &root, int index, u8 recursion) { + if (recursion > 16) { + throw SerializationError("Maximum recursion depth exceeded"); + } int type = lua_type(L, index); if (type == LUA_TBOOLEAN) { root = (bool) lua_toboolean(L, index); @@ -1104,7 +1107,7 @@ void read_json_value(lua_State *L, Json::Value &root, int index) while (lua_next(L, index)) { // Key is at -2 and value is at -1 Json::Value value; - read_json_value(L, value, lua_gettop(L)); + read_json_value(L, value, lua_gettop(L), recursion + 1); Json::ValueType roottype = root.type(); int keytype = lua_type(L, -1); |