Skip to content

Commit

Permalink
Catch errors and OOM when decoding ID3 frames.
Browse files Browse the repository at this point in the history
Invalid frames have no impact on ExoPlayer ability to play the media and should not fail on errors.
Some tools can add 100Mb images in the tags that will trigger recoverable OOM with this fix.
  • Loading branch information
Tolriq authored and icbaker committed Jan 3, 2024
1 parent c230414 commit de772cf
Showing 1 changed file with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,9 @@ private static Id3Frame decodeFrame(
frameSize = removeUnsynchronization(id3Data, frameSize);
}

String error = "";
Id3Frame frame = null;
try {
Id3Frame frame;
if (frameId0 == 'T'
&& frameId1 == 'X'
&& frameId2 == 'X'
Expand Down Expand Up @@ -430,18 +431,24 @@ 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;
} finally {
} catch (Exception e) {
error = ",error=" + e.getMessage();
} catch (OutOfMemoryError e) {
error = ",error=" + e.getMessage();
}
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

0 comments on commit de772cf

Please sign in to comment.