From 9fc018ded10225589d2559d24a5db739e891fb31 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Sun, 29 May 2022 16:00:44 +0200 Subject: Fix use-after-free in node meta cleanup bug introduced in 8908a9101608d3343023b470743ef63f1c44b0b7 --- src/script/lua_api/l_nodemeta.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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(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; -- cgit v1.2.3