Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions Intersect.Client.Core/Interface/Game/Bag/BagItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,28 @@ public BagItem(BagWindow bagWindow, Base parent, int index, ContextMenu contextM

protected override void OnContextMenuOpening(ContextMenu contextMenu)
{
contextMenu.ClearChildren();

if (Globals.BagSlots is not { Length: > 0 } bagSlots)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You removed an OOB check?

This one wasn't sufficient to begin with, but a second check should have been added after instead of removed.

if (SlotIndex >= bagSlots.Length)
{
    return;
}

Copy link
Contributor Author

@Arufonsu Arufonsu Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one isn't sufficient either
we need to check if the slot is valid and return early here

        if (bagSlots[SlotIndex] is null)
        {
            return;
        }

        if (SlotIndex >= bagSlots.Length)
        {
            return;
        }
        if (bankSlots[SlotIndex] is null)
        {
            return;
        }

        if (SlotIndex >= bankSlots.Length)
        {
            return;
        }

otherwise the client crashes !

{
return;
}

if (bagSlots[SlotIndex] is null)
{
return;
}

if (SlotIndex >= bagSlots.Length)
{
return;
}

if (!ItemDescriptor.TryGet(bagSlots[SlotIndex].ItemId, out var item))
{
return;
}

// Clear the context menu and add the withdraw item with updated item name
contextMenu.ClearChildren();
_withdrawContextItem.SetText(Strings.BagContextMenu.Withdraw.ToString(item.Name));
contextMenu.AddChild(_withdrawContextItem);
base.OnContextMenuOpening(contextMenu);
Expand Down
18 changes: 14 additions & 4 deletions Intersect.Client.Core/Interface/Game/Bank/BankItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,31 @@ public BankItem(BankWindow bankWindow, Base parent, int index, ContextMenu conte

protected override void OnContextMenuOpening(ContextMenu contextMenu)
{
contextMenu.ClearChildren(); // Clear context menu

if (Globals.BankSlots is not { Length: > 0 } bankSlots)
{
return;
}

if (bankSlots[SlotIndex] is null)
{
return;
}

if (SlotIndex >= bankSlots.Length)
{
return;
}

if (!ItemDescriptor.TryGet(bankSlots[SlotIndex].ItemId, out var item))
{
return;
}

// Clear the context menu and add the withdraw item with updated item name
contextMenu.ClearChildren();
contextMenu.AddChild(_withdrawContextItem);
// Update context menu
_withdrawContextItem.SetText(Strings.BankContextMenu.Withdraw.ToString(item.Name));

contextMenu.AddChild(_withdrawContextItem);
base.OnContextMenuOpening(contextMenu);
}

Expand Down
Loading