From e23b39abaa9eb08c60bea27024159dcfcd812219 Mon Sep 17 00:00:00 2001 From: TomArnaez <48050423+TomArnaez@users.noreply.github.com> Date: Tue, 28 Feb 2023 19:11:08 +0000 Subject: [PATCH] Fix crash in inventory list (#256) --- src/inventory.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/inventory.cc b/src/inventory.cc index 2d1b832..eaac208 100644 --- a/src/inventory.cc +++ b/src/inventory.cc @@ -2694,7 +2694,9 @@ void inventoryOpenUseItemOn(Object* a1) inventoryWindowOpenContextMenu(keyCode, INVENTORY_WINDOW_TYPE_USE_ITEM_ON); } else { int inventoryItemIndex = _pud->length - (_stack_offset[_curr_stack] + keyCode - 1000 + 1); - if (inventoryItemIndex < _pud->length) { + // SFALL: Fix crash when clicking on empty space in the inventory list + // opened by "Use Inventory Item On" (backpack) action icon + if (inventoryItemIndex < _pud->length && inventoryItemIndex >= 0) { InventoryItem* inventoryItem = &(_pud->items[inventoryItemIndex]); if (isInCombat()) { if (gDude->data.critter.combat.ap >= 2) {