summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/itemcontainer.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 8e05097b5..146a2f328 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -608,8 +608,11 @@ int ItemContainer::getSlotIndex(const int x, const int y) const
if (x < getWidth() && y < getHeight())
{
const int idx = (y / mBoxHeight) * mGridColumns + (x / mBoxWidth);
- if (idx < mGridRows * mGridColumns && mShowMatrix[idx] >= 0)
+ if (idx >= 0 && idx < mGridRows * mGridColumns
+ && mShowMatrix[idx] >= 0)
+ {
return mShowMatrix[idx];
+ }
}
return Inventory::NO_SLOT_INDEX;