aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2018-02-18 10:40:45 +0100
committerSmallJoker <mk939@ymail.com>2018-06-03 17:32:00 +0200
commit858c41b8428fa78039f66b829c0cf8fc92a83212 (patch)
tree72ede6f2be743275a4c2ced915d3813cf6bd5d54 /src/script
parent2a4fbbbff8f555df9984fbff054fe91b1a471d8f (diff)
downloadminetest-858c41b8428fa78039f66b829c0cf8fc92a83212.tar.gz
minetest-858c41b8428fa78039f66b829c0cf8fc92a83212.tar.bz2
minetest-858c41b8428fa78039f66b829c0cf8fc92a83212.zip
Check argument types inside MetaDataRef Lua API (#7045)
Diffstat (limited to 'src/script')
-rw-r--r--src/script/lua_api/l_metadata.cpp12
-rw-r--r--src/script/lua_api/l_nodemeta.cpp2
2 files changed, 7 insertions, 7 deletions
diff --git a/src/script/lua_api/l_metadata.cpp b/src/script/lua_api/l_metadata.cpp
index 5f4e984cb..16cbcc05e 100644
--- a/src/script/lua_api/l_metadata.cpp
+++ b/src/script/lua_api/l_metadata.cpp
@@ -95,7 +95,7 @@ int MetaDataRef::l_get_int(lua_State *L)
MAP_LOCK_REQUIRED;
MetaDataRef *ref = checkobject(L, 1);
- std::string name = lua_tostring(L, 2);
+ std::string name = luaL_checkstring(L, 2);
Metadata *meta = ref->getmeta(false);
if (meta == NULL) {
@@ -114,8 +114,8 @@ int MetaDataRef::l_set_int(lua_State *L)
MAP_LOCK_REQUIRED;
MetaDataRef *ref = checkobject(L, 1);
- std::string name = lua_tostring(L, 2);
- int a = lua_tointeger(L, 3);
+ std::string name = luaL_checkstring(L, 2);
+ int a = luaL_checkint(L, 3);
std::string str = itos(a);
Metadata *meta = ref->getmeta(true);
@@ -133,7 +133,7 @@ int MetaDataRef::l_get_float(lua_State *L)
MAP_LOCK_REQUIRED;
MetaDataRef *ref = checkobject(L, 1);
- std::string name = lua_tostring(L, 2);
+ std::string name = luaL_checkstring(L, 2);
Metadata *meta = ref->getmeta(false);
if (meta == NULL) {
@@ -152,8 +152,8 @@ int MetaDataRef::l_set_float(lua_State *L)
MAP_LOCK_REQUIRED;
MetaDataRef *ref = checkobject(L, 1);
- std::string name = lua_tostring(L, 2);
- float a = lua_tonumber(L, 3);
+ std::string name = luaL_checkstring(L, 2);
+ float a = luaL_checknumber(L, 3);
std::string str = ftos(a);
Metadata *meta = ref->getmeta(true);
diff --git a/src/script/lua_api/l_nodemeta.cpp b/src/script/lua_api/l_nodemeta.cpp
index 5dfa6d52e..0af5eea54 100644
--- a/src/script/lua_api/l_nodemeta.cpp
+++ b/src/script/lua_api/l_nodemeta.cpp
@@ -158,7 +158,7 @@ bool NodeMetaRef::handleFromTable(lua_State *L, int table, Metadata *_meta)
lua_pushnil(L);
while (lua_next(L, inventorytable) != 0) {
// key at index -2 and value at index -1
- std::string name = lua_tostring(L, -2);
+ std::string name = luaL_checkstring(L, -2);
read_inventory_list(L, -1, inv, name.c_str(), getServer(L));
lua_pop(L, 1); // Remove value, keep key for next iteration
}