Fix PacLed64 null-deref on a controller with an unset Id - #59
Merged
Conversation
OnOutputValueChanged used std::map::operator[] on the lazily-populated units map, which inserts a null unit for a missing key and dereferences it; its three siblings (Init/Finish/Update) all guard with find(). A PacLed64 configured without an Id leaves m_id=-1 (Init map-populate skipped for -1), so the first output change null-derefs. C# throws KeyNotFoundException there. Guard with find() like the siblings.
Collaborator
|
Hello. Thanks for the PR! Converting this to draft as per the contributing rules. (I was behind in getting them added as was just done in Visual Pinball). It's going to take time to review these. libdof is currently is use by several users with a variety of devices, and we have yet to receive issues about this. Also this definitely needs thorough testing with the actual hardware. |
jsm174
marked this pull request as draft
July 5, 2026 18:06
jsm174
marked this pull request as ready for review
July 6, 2026 19:08
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix
OnOutputValueChangedusedstd::map::operator[]on the lazily-populated units map — which inserts a null unit for a missing key and then dereferences it. Its three siblings (Init/Finish/Update) all guard withfind(). GuardOnOutputValueChangedthe same way.Why it matters
A PacLed64 configured without an
Idleavesm_id = -1;Init's map-populate is skipped for -1, so the first output change hitss_pacLed64Units[-1]→ insertsnullptr→ null-deref crash. C# pre-populates the dictionary in a static constructor and its indexer throwsKeyNotFoundExceptionthere instead of crashing.Found by diffing against the DirectOutput C# source.