]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Fix use-after-free in node meta cleanup
authorsfan5 <sfan5@live.de>
Sun, 29 May 2022 14:00:44 +0000 (16:00 +0200)
committersfan5 <sfan5@live.de>
Sun, 29 May 2022 14:30:13 +0000 (16:30 +0200)
bug introduced in 8908a9101608d3343023b470743ef63f1c44b0b7

src/script/lua_api/l_nodemeta.cpp

index 514a1b78b18bfe8ae59ed00a214abcdb5d7373ad..bdc4844c0c282ba7906e7bae28ee8825d665cb01 100644 (file)
@@ -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;