Fixed null pointer dereference errors found by cppcheck

This commit is contained in:
Joshua Beck 2011-09-24 02:11:43 -05:00
parent 789c88509c
commit ae561d705f
2 changed files with 5 additions and 4 deletions

@ -1345,8 +1345,6 @@ void ServerEnvironment::deactivateFarObjects(bool force_delete)
i.atEnd()==false; i++) i.atEnd()==false; i++)
{ {
ServerActiveObject* obj = i.getNode()->getValue(); ServerActiveObject* obj = i.getNode()->getValue();
u16 id = i.getNode()->getKey();
v3f objectpos = obj->getBasePosition();
// This shouldn't happen but check it // This shouldn't happen but check it
if(obj == NULL) if(obj == NULL)
@ -1357,6 +1355,9 @@ void ServerEnvironment::deactivateFarObjects(bool force_delete)
continue; continue;
} }
u16 id = i.getNode()->getKey();
v3f objectpos = obj->getBasePosition();
// The block in which the object resides in // The block in which the object resides in
v3s16 blockpos_o = getNodeBlockPos(floatToInt(objectpos, BS)); v3s16 blockpos_o = getNodeBlockPos(floatToInt(objectpos, BS));

@ -4109,7 +4109,7 @@ void Server::UpdateCrafting(u16 peer_id)
InventoryList *clist = player->inventory.getList("craft"); InventoryList *clist = player->inventory.getList("craft");
InventoryList *rlist = player->inventory.getList("craftresult"); InventoryList *rlist = player->inventory.getList("craftresult");
if(rlist->getUsedSlots() == 0) if(rlist && rlist->getUsedSlots() == 0)
player->craftresult_is_preview = true; player->craftresult_is_preview = true;
if(rlist && player->craftresult_is_preview) if(rlist && player->craftresult_is_preview)