Skip to content

Commit 67997af

Browse files
t0suj4est31
authored andcommittedAug 1, 2015
src/environment.cpp: Fix NULL pointer dereference
1 parent 79e2647 commit 67997af

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed
 

Diff for: ‎src/environment.cpp

+13-11
Original file line numberDiff line numberDiff line change
@@ -1820,27 +1820,29 @@ void ServerEnvironment::deactivateFarObjects(bool force_delete)
18201820
bool stays_in_same_block = false;
18211821
bool data_changed = true;
18221822

1823-
if(obj->m_static_exists){
1824-
if(obj->m_static_block == blockpos_o)
1823+
if (obj->m_static_exists) {
1824+
if (obj->m_static_block == blockpos_o)
18251825
stays_in_same_block = true;
18261826

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

1829-
std::map<u16, StaticObject>::iterator n =
1829+
if (block) {
1830+
std::map<u16, StaticObject>::iterator n =
18301831
block->m_static_objects.m_active.find(id);
1831-
if(n != block->m_static_objects.m_active.end()){
1832-
StaticObject static_old = n->second;
1832+
if (n != block->m_static_objects.m_active.end()) {
1833+
StaticObject static_old = n->second;
18331834

1834-
float save_movem = obj->getMinimumSavedMovement();
1835+
float save_movem = obj->getMinimumSavedMovement();
18351836

1836-
if(static_old.data == staticdata_new &&
1837-
(static_old.pos - objectpos).getLength() < save_movem)
1838-
data_changed = false;
1839-
} else {
1840-
errorstream<<"ServerEnvironment::deactivateFarObjects(): "
1837+
if (static_old.data == staticdata_new &&
1838+
(static_old.pos - objectpos).getLength() < save_movem)
1839+
data_changed = false;
1840+
} else {
1841+
errorstream<<"ServerEnvironment::deactivateFarObjects(): "
18411842
<<"id="<<id<<" m_static_exists=true but "
18421843
<<"static data doesn't actually exist in "
18431844
<<PP(obj->m_static_block)<<std::endl;
1845+
}
18441846
}
18451847
}
18461848

0 commit comments

Comments
 (0)
Please sign in to comment.