aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2022-05-29 16:00:44 +0200
committersfan5 <sfan5@live.de>2022-05-29 16:30:13 +0200
commit9fc018ded10225589d2559d24a5db739e891fb31 (patch)
tree7cba6dc169414cc2c0c18703355b32064dcb40f2
parenta9a207685a9d55e4fcdd97f5065383e2ec18e114 (diff)
downloadminetest-9fc018ded10225589d2559d24a5db739e891fb31.tar.gz
minetest-9fc018ded10225589d2559d24a5db739e891fb31.tar.bz2
minetest-9fc018ded10225589d2559d24a5db739e891fb31.zip
Fix use-after-free in node meta cleanup
bug introduced in 8908a9101608d3343023b470743ef63f1c44b0b7
-rw-r--r--src/script/lua_api/l_nodemeta.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/script/lua_api/l_nodemeta.cpp b/src/script/lua_api/l_nodemeta.cpp
index 514a1b78b..bdc4844c0 100644
--- a/src/script/lua_api/l_nodemeta.cpp
+++ b/src/script/lua_api/l_nodemeta.cpp
@@ -66,8 +66,10 @@ void NodeMetaRef::reportMetadataChange(const std::string *name)
NodeMetadata *meta = dynamic_cast<NodeMetadata*>(getmeta(false));
// If the metadata is now empty, get rid of it
- if (meta && meta->empty())
+ if (meta && meta->empty()) {
clearMeta();
+ meta = nullptr;
+ }
MapEditEvent event;
event.type = MEET_BLOCK_NODE_METADATA_CHANGED;