aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2020-04-27 11:27:27 +0200
committerGitHub <noreply@github.com>2020-04-27 11:27:27 +0200
commit91c4f7f0ea0b653d15bfabc05f5474f8fa1a8806 (patch)
tree325d453646277d334a12e886be95a606362182fb /src/script
parentbe71e70a91a3c857652a8b037dac7adf9d0fcdd1 (diff)
downloadminetest-91c4f7f0ea0b653d15bfabc05f5474f8fa1a8806.tar.gz
minetest-91c4f7f0ea0b653d15bfabc05f5474f8fa1a8806.tar.bz2
minetest-91c4f7f0ea0b653d15bfabc05f5474f8fa1a8806.zip
Forbid object:attach(obj, ...) (#9762)
Fixes #9761
Diffstat (limited to 'src/script')
-rw-r--r--src/script/lua_api/l_object.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp
index d7afb84da..77e1e7dc2 100644
--- a/src/script/lua_api/l_object.cpp
+++ b/src/script/lua_api/l_object.cpp
@@ -674,8 +674,13 @@ int ObjectRef::l_set_attach(lua_State *L)
ServerActiveObject *parent = getobject(parent_ref);
if (co == NULL)
return 0;
+
if (parent == NULL)
return 0;
+
+ if (co == parent)
+ throw LuaError("ObjectRef::set_attach: attaching object to itself is not allowed.");
+
// Do it
int parent_id = 0;
std::string bone;