Skip to content

Conversation

@Arufonsu
Copy link
Contributor

@Arufonsu Arufonsu commented Feb 2, 2026

fixes #2805

Signed-off-by: Arufonsu <17498701+Arufonsu@users.noreply.github.com>
@Arufonsu Arufonsu requested a review from a team February 2, 2026 00:03
@Arufonsu Arufonsu added the bug Something isn't working label Feb 2, 2026

protected override void OnContextMenuOpening(ContextMenu contextMenu)
{
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 !

// Clear out the old options since we might not show all of them
contextMenu.ClearChildren();

if (Globals.BagSlots[SlotIndex] is not { } bagSlot)
Copy link
Member

Choose a reason for hiding this comment

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

Replace Globals.BagSlots[SlotIndex] with bagSlots from the first OOBE check

Copy link
Contributor Author

Choose a reason for hiding this comment

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

restored 👍🏽

// Clear out the old options since we might not show all of them
contextMenu.ClearChildren();

if (Globals.BankSlots[SlotIndex] is not { } bankSlot)
Copy link
Member

Choose a reason for hiding this comment

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

All of the same comments from the other file

Signed-off-by: Arufonsu <17498701+Arufonsu@users.noreply.github.com>
@Arufonsu Arufonsu requested a review from pandinocoder February 7, 2026 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: OnContextMenuOpening crashes with empty bag and bank slots

2 participants