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

Commit d7c205fe authored by Wei Jia's avatar Wei Jia Committed by Android Git Automerger
Browse files

am 522019f1: Merge "libstagefright: fix handling of mSampleTimeEntries and...

am 522019f1: Merge "libstagefright: fix handling of mSampleTimeEntries and mNumSampleSizes in SampleTable." into klp-dev

* commit '522019f1':
  libstagefright: fix handling of mSampleTimeEntries and mNumSampleSizes in SampleTable.
parents cb2acbfe 522019f1
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -27,6 +27,11 @@
#include <media/stagefright/DataSource.h>
#include <media/stagefright/Utils.h>

/* TODO: remove after being merged into other branches */
#ifndef UINT32_MAX
#define UINT32_MAX       (4294967295U)
#endif

namespace android {

// static
@@ -282,6 +287,9 @@ status_t SampleTable::setSampleSizeParams(

    mDefaultSampleSize = U32_AT(&header[4]);
    mNumSampleSizes = U32_AT(&header[8]);
    if (mNumSampleSizes > (UINT32_MAX - 12) / 16) {
        return ERROR_MALFORMED;
    }

    if (type == kSampleSizeType32) {
        mSampleSizeFieldSize = 32;
@@ -498,7 +506,7 @@ int SampleTable::CompareIncreasingTime(const void *_a, const void *_b) {
void SampleTable::buildSampleEntriesTable() {
    Mutex::Autolock autoLock(mLock);

    if (mSampleTimeEntries != NULL) {
    if (mSampleTimeEntries != NULL || mNumSampleSizes == 0) {
        return;
    }

@@ -540,6 +548,10 @@ status_t SampleTable::findSampleAtTime(
        uint32_t req_time, uint32_t *sample_index, uint32_t flags) {
    buildSampleEntriesTable();

    if (mSampleTimeEntries == NULL) {
        return ERROR_OUT_OF_RANGE;
    }

    uint32_t left = 0;
    uint32_t right = mNumSampleSizes;
    while (left < right) {