mirror of
https://github.com/samsonjs/media.git
synced 2026-04-05 11:15:46 +00: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
1 changed files with 18 additions and 11 deletions
|
|
@ -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);
|
||||
}
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue