diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-07-26 14:54:34 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-07-26 14:54:34 +1000 |
commit | 2d278e71c15c739a7c9f68e7823ccf3bb7698819 (patch) | |
tree | 99a94a7a65f0c781e173037cef2d2d8ce60e295d /source/game/StarPlayerInventory.cpp | |
parent | a6ac154b944df3c1ff637481043e30873549c276 (diff) |
fix possible segfault in PlayerInventory::retrieve
Diffstat (limited to 'source/game/StarPlayerInventory.cpp')
-rw-r--r-- | source/game/StarPlayerInventory.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/source/game/StarPlayerInventory.cpp b/source/game/StarPlayerInventory.cpp index 0d74e05..c820459 100644 --- a/source/game/StarPlayerInventory.cpp +++ b/source/game/StarPlayerInventory.cpp @@ -1008,9 +1008,10 @@ ItemPtr& PlayerInventory::retrieve(InventorySlot const& slot) { if (auto es = slot.ptr<EquipmentSlot>()) return guardEmpty(m_equipment[*es]); - else if (auto bs = slot.ptr<BagSlot>()) - return guardEmpty(m_bags[bs->first]->at(bs->second)); - else if (slot.is<SwapSlot>()) + else if (auto bs = slot.ptr<BagSlot>()) { + if (auto bag = m_bags.ptr(bs->first)) + return guardEmpty((*bag)->at(bs->second)); + } else if (slot.is<SwapSlot>()) return guardEmpty(m_swapSlot); else return guardEmpty(m_trashSlot); |