Skip to content

Comments

Fix NULL pointer crash in HighlightAvailableStorages#140

Closed
tacticalcatboy wants to merge 1 commit intoArmaOverthrow:mainfrom
tacticalcatboy:main
Closed

Fix NULL pointer crash in HighlightAvailableStorages#140
tacticalcatboy wants to merge 1 commit intoArmaOverthrow:mainfrom
tacticalcatboy:main

Conversation

@tacticalcatboy
Copy link
Contributor

@tacticalcatboy tacticalcatboy commented Dec 1, 2025

Overrides HighlightAvailableStorages in SCR_InventoryMenuUI to add null checks and prevent crashes in the vanilla implementation when certain UI or storage components are missing.

Original error, when you try to move items in your inventory during testing worlds these errors would pop up

Virtual Machine Exception

Reason: NULL pointer to instance

Class: 'SCR_InventoryMenuUI'
Function: 'HighlightAvailableStorages'
Stack trace:
Scripts/Game/UI/Inventory/SCR_InventoryMenuUI.c:5122 Function HighlightAvailableStorages
Scripts/Game/UI/Inventory/SCR_InventoryMenuUI.c:4857 Function Action_OnDrag

Overrides HighlightAvailableStorages in SCR_InventoryMenuUI to add null checks and prevent crashes in the vanilla implementation when certain UI or storage components are missing.

Original error, when you try to move items in your inventory during testing worlds these errors would pop up
"Virtual Machine Exception

Reason: NULL pointer to instance

Class:      'SCR_InventoryMenuUI'
Function: 'HighlightAvailableStorages'
Stack trace:
Scripts/Game/UI/Inventory/SCR_InventoryMenuUI.c:5122 Function HighlightAvailableStorages
Scripts/Game/UI/Inventory/SCR_InventoryMenuUI.c:4857 Function Action_OnDrag"
@tacticalcatboy tacticalcatboy marked this pull request as ready for review December 1, 2025 11:32
@rekterakathom
Copy link
Contributor

I am pretty skeptical about this override because the original method is ~138 lines long and this is less than 30, and also doesn't do a lot of the things that the original does. I suspect that with this override it is possible to desync the inventory UI from what is actually in the inventory, because the original method does a lot of checks for various situations where the storage should not be highlighted for various reasons, whereas this override does none.

Granted, I have not tested this theory.

@rekterakathom
Copy link
Contributor

I identified the root cause to be a missing entity catalogue, specifically the SUPPLY_CONTAINER_ITEM catalogue. I made a pull request #141 to add an empty catalogue of this type to fix the error.

I believe the game should handle it if this catalogue doesn't exist, but that's to be discussed in Feedback Tracker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants