VPAAMP 498 ;Fix for out-of-bound access in CheckPreferredTextLanguages()#1589
Open
Abhi-jith-S wants to merge 1 commit into
Open
VPAAMP 498 ;Fix for out-of-bound access in CheckPreferredTextLanguages()#1589Abhi-jith-S wants to merge 1 commit into
Abhi-jith-S wants to merge 1 commit into
Conversation
Signed-off-by: Abhi-jith-S <abhijithssa7@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a crash in PrivateInstanceAAMP::CheckPreferredTextLanguages() by preventing out-of-bounds access when GetTextTrack() returns an index that is not valid for the currently available text track list (reported timing issue when preferences are set before text tracks are populated).
Changes:
- Added an upper-bound check before indexing
trackInfo[currentTrackIndex]. - Added a warning log when
currentTrackIndexis out of bounds and the code falls back to treating it as “no selection”.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+12587
to
+12591
| if (currentTrackIndex >= static_cast<int>(trackInfo.size())) | ||
| { | ||
| AAMPLOG_WARN("CheckPreferredTextLanguages: currentTrackIndex=%d out of bounds (trackInfo.size()=%zu), treating as no selection", | ||
| currentTrackIndex, trackInfo.size()); | ||
| } |
Comment on lines
+12497
to
12498
| if (currentTrackIndex >= 0 && !(currentTrackIndex >= static_cast<int>(trackInfo.size()))) | ||
| { |
Comment on lines
+12496
to
12498
| //Added out of bound check to prevent crash in case of currentTrackIndex is more than available tracks. | ||
| if (currentTrackIndex >= 0 && !(currentTrackIndex >= static_cast<int>(trackInfo.size()))) | ||
| { |
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.
Reason for change : Fix for out of bound access happened due to a timing issue where in SetPreferredTextLanguages() in AAMP JS was called before PopulateTextTrack was called.
Test Procedure : Refer ticket
Risks : Medium