-
Notifications
You must be signed in to change notification settings - Fork 380
fix: OnContextMenuOpening crash with empty bag and bank slots #2806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Arufonsu <17498701+Arufonsu@users.noreply.github.com>
|
|
||
| protected override void OnContextMenuOpening(ContextMenu contextMenu) | ||
| { | ||
| if (Globals.BagSlots is not { Length: > 0 } bagSlots) |
There was a problem hiding this comment.
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;
}There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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>
fixes #2805