Check NULL pointer properly in some new code trying to log new stuff
authorPerttu Ahola <celeron55@gmail.com>
Sun, 16 Oct 2011 15:50:30 +0000 (18:50 +0300)
committerPerttu Ahola <celeron55@gmail.com>
Sun, 16 Oct 2011 15:50:30 +0000 (18:50 +0300)
src/server.cpp

index a4b6fe649d8d897e4591a02f287bf3f357ffb4bd..33c3b59b300413c63132712dcf5dacaafaa7e295 100644 (file)
@@ -3045,8 +3045,11 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
                                                                player->inventory.getList("craftresult");
                                                assert(list);
                                                InventoryItem *item = list->getItem(0);
+                                               std::string itemname = "NULL";
+                                               if(item)
+                                                       itemname = item->getName();
                                                actionstream<<player->getName()<<" crafts "
-                                                               <<item->getName()<<std::endl;
+                                                               <<itemname<<std::endl;
                                        }
                                        /*
                                                If the craftresult is placed on itself, move it to