aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_mapgen.cpp
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-05-08 20:43:03 +0200
committerGitHub <noreply@github.com>2017-05-08 20:43:03 +0200
commitc07c642ab091b7250ecdc5defee1fec26ba73dc4 (patch)
tree7b84adc4330107416b3a0aee3d4a6b61bb920137 /src/script/lua_api/l_mapgen.cpp
parent5e04f1a3357a618bed6d36b6a7439279b758fc8e (diff)
downloadminetest-c07c642ab091b7250ecdc5defee1fec26ba73dc4.tar.gz
minetest-c07c642ab091b7250ecdc5defee1fec26ba73dc4.tar.bz2
minetest-c07c642ab091b7250ecdc5defee1fec26ba73dc4.zip
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
Diffstat (limited to 'src/script/lua_api/l_mapgen.cpp')
-rw-r--r--src/script/lua_api/l_mapgen.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp
index 6d3171df9..32eb7af84 100644
--- a/src/script/lua_api/l_mapgen.cpp
+++ b/src/script/lua_api/l_mapgen.cpp
@@ -325,14 +325,22 @@ void read_schematic_replacements(lua_State *L, int index, StringMap *replace_nam
if (lua_istable(L, -1)) { // Old {{"x", "y"}, ...} format
lua_rawgeti(L, -1, 1);
+ if (!lua_isstring(L, -1))
+ throw LuaError("schematics: replace_from field is not a string");
replace_from = lua_tostring(L, -1);
lua_pop(L, 1);
lua_rawgeti(L, -1, 2);
+ if (!lua_isstring(L, -1))
+ throw LuaError("schematics: replace_to field is not a string");
replace_to = lua_tostring(L, -1);
lua_pop(L, 1);
} else { // New {x = "y", ...} format
+ if (!lua_isstring(L, -2))
+ throw LuaError("schematics: replace_from field is not a string");
replace_from = lua_tostring(L, -2);
+ if (!lua_isstring(L, -1))
+ throw LuaError("schematics: replace_to field is not a string");
replace_to = lua_tostring(L, -1);
}