Skip to content

Fix crash in Internal::Load when onIl2CppLoaded list is empty - #180

Open
auag0 wants to merge 1 commit into
ByNameModding:masterfrom
auag0:fix-null
Open

Fix crash in Internal::Load when onIl2CppLoaded list is empty#180
auag0 wants to merge 1 commit into
ByNameModding:masterfrom
auag0:fix-null

Conversation

@auag0

@auag0 auag0 commented Sep 9, 2026

Copy link
Copy Markdown

Summary

Fixed a crash that occurred in Internal::Load when no events were registered in onIl2CppLoaded.

Problem

The BNM::ForwardList used for onIl2CppLoaded is a circular linked list.
When the list is empty, lastElement is nullptr. The existing code attempted to access lastElement->next without checking if the list was empty, leading to a null pointer dereference and a crash.

Solution

Added an IsEmpty() check before entering the event dispatching loop.
If no events are registered, the function now returns early safely.

Impact

  • Prevents crashes when AddOnLoadedEvent has not been called.
  • Ensures safe behavior regardless of whether events are registered.
  • No negative impact on existing functionality.

Test

Verified that the application no longer crashes when the event list is empty, and events are still called correctly when registered.

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.

1 participant