Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 0ab3e6a

Browse files
committed
Fixed some potential crashes in inventorymenugui caused by a lack of safety checks
1 parent 4e56d65 commit 0ab3e6a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Menus/InventoryMenuGUI.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ namespace RTE {
303303
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
304304

305305
bool InventoryMenuGUI::EnableIfNotEmpty() {
306-
bool shouldEnable = !m_InventoryActorEquippedItems.empty() || !m_InventoryActor->IsInventoryEmpty();
306+
bool shouldEnable = !m_InventoryActorEquippedItems.empty() || (m_InventoryActor && !m_InventoryActor->IsInventoryEmpty());
307307
SetEnabled(shouldEnable);
308308
return shouldEnable;
309309
}
@@ -725,10 +725,12 @@ namespace RTE {
725725
};
726726

727727
for (const auto &[button, icon] : buttonsToCheckIconsFor) {
728-
if (button->IsEnabled()) {
729-
button->SetIcon((button->HasFocus() || button->IsMousedOver() || button->IsPushed()) ? icon->GetBitmaps8()[1] : icon->GetBitmaps8()[0]);
730-
} else {
731-
button->SetIcon(icon->GetBitmaps8()[2]);
728+
if (icon) {
729+
if (button->IsEnabled()) {
730+
button->SetIcon((button->HasFocus() || button->IsMousedOver() || button->IsPushed()) ? icon->GetBitmaps8()[1] : icon->GetBitmaps8()[0]);
731+
} else {
732+
button->SetIcon(icon->GetBitmaps8()[2]);
733+
}
732734
}
733735

734736
if (!button->IsEnabled() && button->GetWidth() == 15 && (button->HasFocus() || button->IsMousedOver() || button->IsPushed())) {

0 commit comments

Comments
 (0)