Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit be1195a6 authored by Marco Nelissen's avatar Marco Nelissen
Browse files

Fix SIGABRT when playing mp4 file

If the track duration was shorter than the segment duration, the calculated
encoder padding would be negative, resulting in a crash.
b/11823061
https://code.google.com/p/android/issues/detail?id=62610

Change-Id: I3989ad88caea38d212b61355c15aec13382c6116
parent 880413f7
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -960,6 +960,12 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
                    mLastTrack->meta->setInt32(kKeyEncoderDelay, delay);

                    int64_t paddingus = duration - (segment_duration + media_time);
                    if (paddingus < 0) {
                        // track duration from media header (which is what kKeyDuration is) might
                        // be slightly shorter than the segment duration, which would make the
                        // padding negative. Clamp to zero.
                        paddingus = 0;
                    }
                    int64_t paddingsamples = (paddingus * samplerate + 500000) / 1000000;
                    mLastTrack->meta->setInt32(kKeyEncoderPadding, paddingsamples);
                }