summaryrefslogtreecommitdiff
path: root/src/gui/windows/buydialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/windows/buydialog.cpp')
-rw-r--r--src/gui/windows/buydialog.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp
index fa7297bdd..9dd083d61 100644
--- a/src/gui/windows/buydialog.cpp
+++ b/src/gui/windows/buydialog.cpp
@@ -617,7 +617,11 @@ void BuyDialog::updateSlider(const int selectedItem)
// Update money and adjust the max number of items
// that can be bought
mMaxItems -= mAmountItems;
- setMoney(mMoney - mAmountItems * mShopItems->at(selectedItem)->getPrice());
+ const ShopItem *const item = mShopItems->at(selectedItem);
+ if (item)
+ setMoney(mMoney - mAmountItems * item->getPrice());
+ else
+ setMoney(mMoney);
// Reset selection
mAmountItems = 1;