Skip to content

Commit

Permalink
Fix two nul deref if digging unknown nodes. (#5398)
Browse files Browse the repository at this point in the history
Introduced by d785456 (#5162)
  • Loading branch information
sofar authored and nerzhul committed Mar 15, 2017
1 parent 84f4565 commit b539985
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions builtin/game/item.lua
Expand Up @@ -496,15 +496,15 @@ function core.node_dig(pos, node, digger)
core.handle_node_drops(pos, drops, digger)

local oldmetadata = nil
if def.after_dig_node then
if def and def.after_dig_node then
oldmetadata = core.get_meta(pos):to_table()
end

-- Remove node and update
core.remove_node(pos)

-- Run callback
if def.after_dig_node then
if def and def.after_dig_node then
-- Copy pos and node because callback can modify them
local pos_copy = {x=pos.x, y=pos.y, z=pos.z}
local node_copy = {name=node.name, param1=node.param1, param2=node.param2}
Expand Down

0 comments on commit b539985

Please sign in to comment.