summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-06-01 19:33:20 +0300
committerPerttu Ahola <celeron55@gmail.com>2012-06-03 22:31:00 +0300
commit7d6e80a423f75aa15d95233852979713d9c99625 (patch)
tree3ff930cb1f200907e4f4898f59612c251d2deba9
parentf3ec1452cdf73d62f38b0222dcbf8bc78293206d (diff)
downloadminetest-7d6e80a423f75aa15d95233852979713d9c99625.tar.gz
minetest-7d6e80a423f75aa15d95233852979713d9c99625.tar.bz2
minetest-7d6e80a423f75aa15d95233852979713d9c99625.zip
Add proper error messages to GUIInventoryMenu when inventory lists are invalid
-rw-r--r--src/guiInventoryMenu.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/guiInventoryMenu.cpp b/src/guiInventoryMenu.cpp
index f33460906..c7cff329e 100644
--- a/src/guiInventoryMenu.cpp
+++ b/src/guiInventoryMenu.cpp
@@ -531,10 +531,18 @@ bool GUIInventoryMenu::OnEvent(const SEvent& event)
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() &&