Chests: Fix crash on empty key metadata
authorSmallJoker <SmallJoker@users.noreply.github.com>
Thu, 18 Oct 2018 04:45:35 +0000 (06:45 +0200)
committerParamat <paramat@users.noreply.github.com>
Thu, 18 Oct 2018 04:45:35 +0000 (05:45 +0100)
mods/default/chests.lua

index cd7079919b1b406018027bf296fb3b188f2c0211..333890564ea77a6bafacdc145e0641290018155c 100644 (file)
@@ -147,6 +147,10 @@ function default.chest.register_chest(name, d)
                        local itemstack = player:get_wielded_item()
                        local key_meta = itemstack:get_meta()
 
+                       if itemstack:get_metadata() == "" then
+                               return
+                       end
+
                        if key_meta:get_string("secret") == "" then
                                key_meta:set_string("secret", minetest.parse_json(itemstack:get_metadata()).secret)
                                itemstack:set_metadata("")