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

Catch errors and OOM when decoding ID3 frames. #369

Merged
merged 3 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@
* Fix bug where `MediaMetadata` was only populated from Vorbis comments
with upper-case keys
([#876](https://github.com/androidx/media/issues/876)).
* Catch `OutOfMemoryError` when parsing very large ID3 frames, meaning
playback can continue without the tag info instead of playback failing
completely.
* DRM:
* Extend workaround for spurious ClearKey `https://default.url` license
URL to API 33+ (previously the workaround only applied on API 33
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,9 @@ private static Id3Frame decodeFrame(
frameSize = removeUnsynchronization(id3Data, frameSize);
}

Id3Frame frame = null;
Throwable error = null;
try {
Id3Frame frame;
if (frameId0 == 'T'
&& frameId1 == 'X'
&& frameId2 == 'X'
Expand Down Expand Up @@ -430,18 +431,21 @@ private static Id3Frame decodeFrame(
String id = getFrameId(majorVersion, frameId0, frameId1, frameId2, frameId3);
frame = decodeBinaryFrame(id3Data, frameSize, id);
}
if (frame == null) {
Log.w(
TAG,
"Failed to decode frame: id="
+ getFrameId(majorVersion, frameId0, frameId1, frameId2, frameId3)
+ ", frameSize="
+ frameSize);
}
return frame;
} catch (OutOfMemoryError | Exception e) {
error = e;
} finally {
id3Data.setPosition(nextFramePosition);
}
if (frame == null) {
Log.w(
TAG,
"Failed to decode frame: id="
+ getFrameId(majorVersion, frameId0, frameId1, frameId2, frameId3)
+ ", frameSize="
+ frameSize,
error);
}
return frame;
}

@Nullable
Expand Down