Fix nil deref issue with people hitting chests too often.
authorAuke Kok <sofar@foo-projects.org>
Sun, 7 May 2017 04:15:34 +0000 (21:15 -0700)
committerAuke Kok <sofar+github@foo-projects.org>
Mon, 8 May 2017 03:47:17 +0000 (20:47 -0700)
mods/default/nodes.lua

index c410b21391b9b876067db340493c50721c617a9a..a1da9216afa4244f81bf8e056808af5561bcf926 100644 (file)
@@ -1801,11 +1801,15 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
        if formname ~= "default:chest" then
                return
        end
-       if not fields.quit then
+       if not player or not fields.quit then
                return
        end
        local pn = player:get_player_name()
 
+       if not open_chests[pn] then
+               return
+       end
+
        local pos = open_chests[pn].pos
        local sound = open_chests[pn].sound
        local swap = open_chests[pn].swap