assert(inv_s);
InventoryList *list = inv_s->getList(s.listname);
- if(list != NULL && (u32) s.i < list->getSize())
- s_count = list->getItem(s.i).count;
- else
+ if(list == NULL){
+ errorstream<<"InventoryMenu: The selected inventory list "
+ <<"does not exist"<<std::endl;
+ s.i = -1; // make it invalid again
+ } else if((u32)s.i >= list->getSize()){
+ errorstream<<"InventoryMenu: The selected inventory list "
+ <<"is too small (i="<<s.i<<", size="
+ <<list->getSize()<<")"<<std::endl;
s.i = -1; // make it invalid again
+ } else{
+ s_count = list->getItem(s.i).count;
+ }
}
bool identical = (m_selected_item != NULL) && s.isValid() &&