From 58b48e17eaf5030a44b8dc438192197844a85342 Mon Sep 17 00:00:00 2001 From: staphen Date: Thu, 16 Feb 2023 22:36:58 -0500 Subject: [PATCH] Fix OOB access when accessing stash --- Source/qol/stash.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/qol/stash.cpp b/Source/qol/stash.cpp index 503ec3465..1fbdaa6b0 100644 --- a/Source/qol/stash.cpp +++ b/Source/qol/stash.cpp @@ -357,10 +357,11 @@ void DrawStash(const Surface &out) for (auto slot : StashGridRange) { StashStruct::StashCell itemId = Stash.GetItemIdAtPosition(slot); - Item &item = Stash.stashList[itemId]; - if (Stash.IsItemAtPosition(slot)) { - InvDrawSlotBack(out, GetStashSlotCoord(slot) + offset, InventorySlotSizeInPixels, item._iMagical); + if (itemId == StashStruct::EmptyCell) { + continue; // No item in the given slot } + Item &item = Stash.stashList[itemId]; + InvDrawSlotBack(out, GetStashSlotCoord(slot) + offset, InventorySlotSizeInPixels, item._iMagical); } for (auto slot : StashGridRange) {