summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParamat <paramat@users.noreply.github.com>2017-05-23 18:54:37 +0100
committerLoïc Blot <nerzhul@users.noreply.github.com>2017-05-23 19:54:37 +0200
commit9ff5302c8bf1cc270ca144c9f2cfcb99f6903605 (patch)
tree4a57258b2607acd045145985e3082f7a0717194b
parent05309229b847ea4f289328890176d22c4655348b (diff)
downloadminetest-9ff5302c8bf1cc270ca144c9f2cfcb99f6903605.tar.gz
minetest-9ff5302c8bf1cc270ca144c9f2cfcb99f6903605.tar.bz2
minetest-9ff5302c8bf1cc270ca144c9f2cfcb99f6903605.zip
Client crashfix: load meta after digging (#5801)
Fixes a crash caused in MTGame by breaking and right-clicking a chest. If loading meta, digging, node can disappear and we looked at meta, which is wrong because meta became NULL. Pointer is invalidated and we read wrong memory area
-rw-r--r--src/game.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 5d4edb3d0..1ddf07fd1 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -3744,6 +3744,13 @@ void Game::handlePointingAtNode(const PointedThing &pointed, const ItemDefinitio
*/
ClientMap &map = client->getEnv().getClientMap();
+
+ if (runData.nodig_delay_timer <= 0.0 && isLeftPressed()
+ && client->checkPrivilege("interact")) {
+ handleDigging(pointed, nodepos, playeritem_toolcap, dtime);
+ }
+
+ // This should be done after digging handling
NodeMetadata *meta = map.getNodeMetadata(nodepos);
if (meta) {
@@ -3757,11 +3764,6 @@ void Game::handlePointingAtNode(const PointedThing &pointed, const ItemDefinitio
}
}
- if (runData.nodig_delay_timer <= 0.0 && isLeftPressed()
- && client->checkPrivilege("interact")) {
- handleDigging(pointed, nodepos, playeritem_toolcap, dtime);
- }
-
if ((getRightClicked() ||
runData.repeat_rightclick_timer >= m_repeat_right_click_time) &&
client->checkPrivilege("interact")) {
@@ -3977,10 +3979,9 @@ void Game::handleDigging(const PointedThing &pointed, const v3s16 &nodepos,
bool is_valid_position;
MapNode wasnode = map.getNodeNoEx(nodepos, &is_valid_position);
if (is_valid_position) {
- if (client->moddingEnabled()) {
- if (client->getScript()->on_dignode(nodepos, wasnode)) {
- return;
- }
+ if (client->moddingEnabled() &&
+ client->getScript()->on_dignode(nodepos, wasnode)) {
+ return;
}
client->removeNode(nodepos);
}