summaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_object.cpp
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2019-03-12 07:56:56 +0000
committerLoïc Blot <nerzhul@users.noreply.github.com>2019-03-12 08:56:56 +0100
commit1e3e4fb6492832048b484ffe784613a16713f1d2 (patch)
tree672f8699f84afba9bd238bd5a0173e175d1ab260 /src/script/lua_api/l_object.cpp
parent3b25b807f33bff885bd840ec0dc9e2d95b392f81 (diff)
downloadminetest-1e3e4fb6492832048b484ffe784613a16713f1d2.tar.gz
minetest-1e3e4fb6492832048b484ffe784613a16713f1d2.tar.bz2
minetest-1e3e4fb6492832048b484ffe784613a16713f1d2.zip
HPChange Reason: Fix push after free, and type being overwritten (#8359)
* HPChange Reason: Fix push after free, and type being overwritten Fixes #8227 and #8344
Diffstat (limited to 'src/script/lua_api/l_object.cpp')
-rw-r--r--src/script/lua_api/l_object.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp
index 9edb2f4f8..b3ed39c7c 100644
--- a/src/script/lua_api/l_object.cpp
+++ b/src/script/lua_api/l_object.cpp
@@ -257,6 +257,9 @@ int ObjectRef::l_set_hp(lua_State *L)
if (co->getType() == ACTIVEOBJECT_TYPE_PLAYER)
getServer(L)->SendPlayerHPOrDie((PlayerSAO *)co, reason);
+ if (reason.hasLuaReference())
+ luaL_unref(L, LUA_REGISTRYINDEX, reason.lua_reference);
+
// Return
return 0;
}