Skip to content
Permalink
Browse files

src/environment.cpp: Fix NULL pointer dereference

  • Loading branch information
t0suj4 authored and est31 committed Aug 1, 2015
1 parent 79e2647 commit 67997af67fbf7c95e78574f810aa322275b3eb66
Showing with 13 additions and 11 deletions.
  1. +13 −11 src/environment.cpp
@@ -1820,27 +1820,29 @@ void ServerEnvironment::deactivateFarObjects(bool force_delete)
bool stays_in_same_block = false;
bool data_changed = true;

if(obj->m_static_exists){
if(obj->m_static_block == blockpos_o)
if (obj->m_static_exists) {
if (obj->m_static_block == blockpos_o)
stays_in_same_block = true;

MapBlock *block = m_map->emergeBlock(obj->m_static_block, false);

std::map<u16, StaticObject>::iterator n =
if (block) {
std::map<u16, StaticObject>::iterator n =
block->m_static_objects.m_active.find(id);
if(n != block->m_static_objects.m_active.end()){
StaticObject static_old = n->second;
if (n != block->m_static_objects.m_active.end()) {
StaticObject static_old = n->second;

float save_movem = obj->getMinimumSavedMovement();
float save_movem = obj->getMinimumSavedMovement();

if(static_old.data == staticdata_new &&
(static_old.pos - objectpos).getLength() < save_movem)
data_changed = false;
} else {
errorstream<<"ServerEnvironment::deactivateFarObjects(): "
if (static_old.data == staticdata_new &&
(static_old.pos - objectpos).getLength() < save_movem)
data_changed = false;
} else {
errorstream<<"ServerEnvironment::deactivateFarObjects(): "
<<"id="<<id<<" m_static_exists=true but "
<<"static data doesn't actually exist in "
<<PP(obj->m_static_block)<<std::endl;
}
}
}

0 comments on commit 67997af

Please sign in to comment.