Fix two nul deref if digging unknown nodes. (#5398)

Introduced by d785456b3fa35faf47cb972fde9e8668382c5e22 (#5162)
This commit is contained in:
Auke Kok 2017-03-15 00:04:53 -07:00 committed by Loïc Blot
parent 84f4565e13
commit b539985ab8

@ -496,7 +496,7 @@ function core.node_dig(pos, node, digger)
core.handle_node_drops(pos, drops, digger) core.handle_node_drops(pos, drops, digger)
local oldmetadata = nil local oldmetadata = nil
if def.after_dig_node then if def and def.after_dig_node then
oldmetadata = core.get_meta(pos):to_table() oldmetadata = core.get_meta(pos):to_table()
end end
@ -504,7 +504,7 @@ function core.node_dig(pos, node, digger)
core.remove_node(pos) core.remove_node(pos)
-- Run callback -- 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 -- Copy pos and node because callback can modify them
local pos_copy = {x=pos.x, y=pos.y, z=pos.z} local pos_copy = {x=pos.x, y=pos.y, z=pos.z}
local node_copy = {name=node.name, param1=node.param1, param2=node.param2} local node_copy = {name=node.name, param1=node.param1, param2=node.param2}