Skip to content

VPAAMP-498 : Fix for out-of-bound access in CheckPreferredTextLanguages()#1590

Open
Abhi-jith-S wants to merge 1 commit into
dev_sprint_25_2from
feature/VPAAMP-498_sprint
Open

VPAAMP-498 : Fix for out-of-bound access in CheckPreferredTextLanguages()#1590
Abhi-jith-S wants to merge 1 commit into
dev_sprint_25_2from
feature/VPAAMP-498_sprint

Conversation

@Abhi-jith-S

Copy link
Copy Markdown
Contributor

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

Signed-off-by: Abhi-jith-S <abhijithssa7@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a crash in PrivateInstanceAAMP::CheckPreferredTextLanguages() by preventing out-of-bounds access when SetPreferredTextLanguages() is invoked (via AAMP JS) before text tracks have been populated.

Changes:

  • Add bounds checking around currentTrackIndex before indexing into trackInfo.
  • Add a warning log when currentTrackIndex is out of bounds and is treated as “no selection”.

Comment thread priv_aamp.cpp
Comment on lines +13194 to 13196
//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())))
{
Comment thread priv_aamp.cpp
Comment on lines +13285 to +13288
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());
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