Make GUIinventoryMenu::drawList more robust with invalid data
authorPerttu Ahola <celeron55@gmail.com>
Sat, 2 Jun 2012 12:28:12 +0000 (15:28 +0300)
committerPerttu Ahola <celeron55@gmail.com>
Sun, 3 Jun 2012 19:31:01 +0000 (22:31 +0300)
src/guiInventoryMenu.cpp

index 51001eee3c3657737b88eafc08a686e358535e11..e637ab78ae7136ffddb14d5662ad0fe77715aacb 100644 (file)
@@ -284,8 +284,21 @@ void GUIInventoryMenu::drawList(const ListDrawSpec &s, int phase)
                font = skin->getFont();
        
        Inventory *inv = m_invmgr->getInventory(s.inventoryloc);
-       assert(inv);
+       if(!inv){
+               infostream<<"GUIInventoryMenu::drawList(): WARNING: "
+                               <<"The inventory location "
+                               <<"\""<<s.inventoryloc.dump()<<"\" doesn't exist"
+                               <<std::endl;
+               return;
+       }
        InventoryList *ilist = inv->getList(s.listname);
+       if(!ilist){
+               infostream<<"GUIInventoryMenu::drawList(): WARNING: "
+                               <<"The inventory list \""<<s.listname<<"\" @ \""
+                               <<s.inventoryloc.dump()<<"\" doesn't exist"
+                               <<std::endl;
+               return;
+       }
        
        core::rect<s32> imgrect(0,0,imgsize.X,imgsize.Y);