Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tv-casting-app: fix TargetVideoPlayerInfo mem corruption #257

Merged
merged 1 commit into from
Feb 8, 2024

Conversation

sharadb-amazon
Copy link
Owner

@sharadb-amazon sharadb-amazon commented Feb 2, 2024

Problem

The IPAddress and MACAddress fields (in the TargetVideoPlayerInfo), required for the WakeOnLAN implementation, were sometimes getting corrupted when the VerifyOrEstablishConnectionTask() API is called. This was because the VerifyOrEstablishConnection() API gets a reference to the targetVideoPlayerInfo that is created on the stack by the caller. If we copy the input param targetVideoPlayerInfo to the mActiveTargetVideoPlayerInfo, the underlying memory for the IPAddress and MACAddress may get deallocated as the original targetVideoPlayerInfo goes out of scope of the caller.

Solution

Find the index of the targetVideoPlayerInfo in the mCachedTargetVideoPlayerInfo array that is held in the CastingServer class as a data member. Then copy the cached equivalent of the targetVideoPlayerInfo to mActiveTargetVideoPlayerInfo. This way the memory locations the mActiveTargetVideoPlayerInfo stays valid during a connection attempt, as the mCachedTargetVideoPlayerInfo[] is a CastingServer class data member.

Testing

Tested using the android tv-casting-app running against the Linux tv-app and checked that the IP Address and MAC Address fields now stay valid.

Copy link

github-actions bot commented Feb 2, 2024

All PRs require an issue to be accepted, please link an issue or mention it in the body using #<issue_id>

1 similar comment
Copy link

github-actions bot commented Feb 3, 2024

All PRs require an issue to be accepted, please link an issue or mention it in the body using #<issue_id>

Copy link

github-actions bot commented Feb 5, 2024

All PRs require an issue to be accepted, please link an issue or mention it in the body using #<issue_id>

@sharadb-amazon sharadb-amazon merged commit 1f078a8 into v1.0.0-branch Feb 8, 2024
5 of 86 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants