Skip to content

Commit c07c642

Browse files
authoredMay 8, 2017
read_schematic_replacements: ensure fields are strings (#5726)
* read_schematic_replacements: ensure fields are strings add a type check before reading strings on read_schematic_replacements deserializer * throw LuaError instead of asserting the whole client
1 parent 5e04f1a commit c07c642

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
 

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

+8
Original file line numberDiff line numberDiff line change
@@ -325,14 +325,22 @@ void read_schematic_replacements(lua_State *L, int index, StringMap *replace_nam
325325

326326
if (lua_istable(L, -1)) { // Old {{"x", "y"}, ...} format
327327
lua_rawgeti(L, -1, 1);
328+
if (!lua_isstring(L, -1))
329+
throw LuaError("schematics: replace_from field is not a string");
328330
replace_from = lua_tostring(L, -1);
329331
lua_pop(L, 1);
330332

331333
lua_rawgeti(L, -1, 2);
334+
if (!lua_isstring(L, -1))
335+
throw LuaError("schematics: replace_to field is not a string");
332336
replace_to = lua_tostring(L, -1);
333337
lua_pop(L, 1);
334338
} else { // New {x = "y", ...} format
339+
if (!lua_isstring(L, -2))
340+
throw LuaError("schematics: replace_from field is not a string");
335341
replace_from = lua_tostring(L, -2);
342+
if (!lua_isstring(L, -1))
343+
throw LuaError("schematics: replace_to field is not a string");
336344
replace_to = lua_tostring(L, -1);
337345
}
338346

0 commit comments

Comments
 (0)
Please sign in to comment.