Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Fix two nul deref if digging unknown nodes. (#5398)
- Loading branch information
Showing
with
2 additions
and
2 deletions.
-
+2
−2
builtin/game/item.lua
|
@@ -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} |
|
|