Skip to content

VPAAMP-387 missing null pointer guards for mMediaStreamContext[eMEDIATYPE_VIDEO] and mMediaStreamContext[eMEDIATYPE_AUDIO]#1487

Merged
pstroffolino merged 6 commits into
dev_sprint_25_2from
feature/VPAAMP-387
May 24, 2026
Merged

VPAAMP-387 missing null pointer guards for mMediaStreamContext[eMEDIATYPE_VIDEO] and mMediaStreamContext[eMEDIATYPE_AUDIO]#1487
pstroffolino merged 6 commits into
dev_sprint_25_2from
feature/VPAAMP-387

Conversation

@pstroffolino
Copy link
Copy Markdown
Contributor

@pstroffolino pstroffolino commented May 20, 2026

Reason for Change: static code analysis noted some missing null pointer guards - appears to be longstanding issue

Test Guidance: will add new test to force the path that otherwise would have caused crash

Risk: Low

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 targets VPAAMP-387 by adding null-pointer guards in StreamAbstractionAAMP_MPD::StreamSelection() to prevent potential crashes when accessing mMediaStreamContext[eMEDIATYPE_VIDEO] / mMediaStreamContext[eMEDIATYPE_AUDIO].

Changes:

  • Added a null check for video/audio mMediaStreamContext entries before the “audio-only period” handling block.
  • Added an error log when a null track context is detected.

Comment thread fragmentcollector_mpd.cpp Outdated
…TYPE_VIDEO] and mMediaStreamContext[eMEDIATYPE_AUDIO]

Reason for Change: static code analysis noted some missing null pointed guards - appears to be longstanding issue

Signed-off-by: Philip Stroffolino <philip_stroffolino@cable.comcast.com>
Signed-off-by: Philip Stroffolino <philip_stroffolino@cable.comcast.com>
@pstroffolino pstroffolino force-pushed the feature/VPAAMP-387 branch 2 times, most recently from 5fb7677 to eb88997 Compare May 23, 2026 15:16
@pstroffolino pstroffolino requested a review from Copilot May 23, 2026 15:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread fragmentcollector_mpd.cpp Outdated
Comment thread fragmentcollector_mpd.cpp Outdated
Null-check at the audio-only block only logged but did not prevent
subsequent dereferences of mMediaStreamContext[eMEDIATYPE_AUDIO] and
[eMEDIATYPE_VIDEO] (e.g. SetCurrentBandWidth, audio-only copy block).
Add early return so all downstream uses are skipped when either context
is null.
pstroffolino and others added 2 commits May 23, 2026 14:32
…ion test

Adds StreamSelection_TrickPlay_NullAudioContext_DoesNotCrash to
StreamSelectionTests.  The test initializes at trick-play rate (4x) so
that mMaxTracks==1 and mMediaStreamContext[eMEDIATYPE_AUDIO] remains
null, then calls InvokeStreamSelection() under EXPECT_NO_FATAL_FAILURE
to confirm the null guard on the audio-only copy block and the targeted
null guard in the SetCurrentBandWidth loop both hold.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (2)

test/utests/tests/StreamAbstractionAAMP_MPD/StreamSelectionTest.cpp:825

  • EXPECT_NO_FATAL_FAILURE does not protect against process crashes/segfaults, so it doesn’t actually validate the stated “DoesNotCrash” intent (a null dereference would still abort the whole test binary). Consider calling InvokeStreamSelection() directly (a crash will fail the test run) and/or adjust the assertion/comment to reflect what is actually being checked (no gtest fatal failures).
	// StreamSelection() must complete without dereferencing the null audio
	// context.  Both guard sites (audio-only copy block and SetCurrentBandWidth
	// loop) are reached in this path.
	EXPECT_NO_FATAL_FAILURE(mStreamAbstractionAAMP_MPD->InvokeStreamSelection());

fragmentcollector_mpd.cpp:7326

  • AAMPLOG_ERR("... null track context in audio-only check") doesn’t indicate which context is null (audio vs video) or include useful state (e.g., play rate / mMaxTracks / mNumberOfTracks), which makes triage harder. Consider expanding the message to include which pointer(s) are null and relevant track/rate context.
		if (mPlayRate == AAMP_NORMAL_PLAY_RATE)
		{
			AAMPLOG_ERR("StreamAbstractionAAMP_MPD: null track context in audio-only check");
		}

Comment thread test/utests/tests/StreamAbstractionAAMP_MPD/StreamSelectionTest.cpp Outdated
Comment thread fragmentcollector_mpd.cpp Outdated
The null dereferences of mMediaStreamContext[eMEDIATYPE_AUDIO] at the
audio-only copy block and the SetCurrentBandWidth call are logically
unreachable at trick-play rate:

- The audio-only copy block fires when mNumberOfTracks==1 and
  mMediaStreamContext[eMEDIATYPE_VIDEO]->enabled==false.  At trick-play
  rate the only code path that sets mNumberOfTracks=1 is the iframe-track
  branch, which also unconditionally sets enabled=true, making !enabled
  false.  The two conditions are mutually exclusive.

- The SetCurrentBandWidth call is inside the aTracks loop.  SelectAudioTrack
  is only called at AAMP_NORMAL_PLAY_RATE, so aTracks is always empty at
  trick-play rate and the loop body is never entered.

At normal play rate all contexts are allocated (mMaxTracks==AAMP_TRACK_COUNT),
so neither dereference is unsafe there either.

Replace the runtime guards and the regression test with comments at each
site that document the invariant and the reasoning, so reviewers and future
authors understand why the code is safe without dead guard code.
@pstroffolino pstroffolino merged commit 46d188a into dev_sprint_25_2 May 24, 2026
8 checks passed
@pstroffolino pstroffolino deleted the feature/VPAAMP-387 branch May 24, 2026 13:45
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