fix: avoid out-of-bounds array access in modelinfomgr - #230
Merged
AmeerDotEXE merged 1 commit intoAug 1, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens ModelInfoMgr::SetEditableMaterialsCB against out-of-bounds reads when resolving siren/strobe material states by validating indices returned from GetSirenIndex / GetStrobeIndex, removing the prior frame-count-based workaround.
Changes:
- Removed the early-return “frame count <= 10” workaround for siren materials.
- Added explicit bounds checks before reading
m_SirenStatus[]andm_StrobeStatus[]using the computed indices.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Proper bounds checking for indices returned by GetSirenIndex and GetStrobeIndex before accessing the associated status arrays.
AmeerDotEXE
force-pushed
the
fix-modelinfomgr-bounds-check-2942288192757790142
branch
from
August 1, 2026 19:55
c5cb692 to
13faa11
Compare
Collaborator
|
added back the siren check, it will be removed by the next pr. thanks for helping :D |
CanerKaraca23
deleted the
fix-modelinfomgr-bounds-check-2942288192757790142
branch
August 1, 2026 21:27
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.
🎯 What: Removed a hacky
data.nFrameCount <= 10check used to workaround a crash and replaced it with strict bounds checking before accessingm_SirenStatusandm_StrobeStatusarrays based onGetSirenIndex/GetStrobeIndex.💡 Why: The frame count check delayed the bug but didn't actually fix the root cause, which was out-of-bounds array reads. Checking the index ensures memory safety regardless of the frame counter, which is cleaner and less susceptible to race conditions.
✅ Verification: Verified by a code reviewer confirming the logical correctness of checking array limits
idx >= 0 && idx < MAX_LIGHTSbefore proceeding with the read. Avoided polluting the repo withcompile_commands.jsonorplugin-sdkdownloads.✨ Result: Improved crash resilience and robustness for vehicle material rendering without arbitrary frame delay workarounds.