mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Catch errors and OOM when decoding ID3 frames.
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.
This commit is contained in:
parent
c230414bd3
commit
de772cfbf0
@ -372,8 +372,9 @@ public final class Id3Decoder extends SimpleMetadataDecoder {
|
||||
frameSize = removeUnsynchronization(id3Data, frameSize);
|
||||
}
|
||||
|
||||
String error = "";
|
||||
Id3Frame frame = null;
|
||||
try {
|
||||
Id3Frame frame;
|
||||
if (frameId0 == 'T'
|
||||
&& frameId1 == 'X'
|
||||
&& frameId2 == 'X'
|
||||
@ -430,18 +431,24 @@ public final class Id3Decoder extends SimpleMetadataDecoder {
|
||||
String id = getFrameId(majorVersion, frameId0, frameId1, frameId2, frameId3);
|
||||
frame = decodeBinaryFrame(id3Data, frameSize, id);
|
||||
}
|
||||
} 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);
|
||||
+ frameSize
|
||||
+ error);
|
||||
}
|
||||
return frame;
|
||||
} finally {
|
||||
id3Data.setPosition(nextFramePosition);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
Loading…
x
Reference in New Issue
Block a user