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

Commit 719cd33e authored by Marco Nelissen's avatar Marco Nelissen Committed by Android Git Automerger
Browse files

am 492bba08: am d18bb120: am 09f71c56: am dedaca6f: Limit allocations to avoid out-of-memory

* commit '492bba08':
  Limit allocations to avoid out-of-memory
parents 4bb4736e 492bba08
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -3089,16 +3089,24 @@ status_t MPEG4Source::start(MetaData *params) {
        mWantsNALFragments = false;
    }

    int32_t tmp;
    CHECK(mFormat->findInt32(kKeyMaxInputSize, &tmp));
    size_t max_size = tmp;

    // A somewhat arbitrary limit that should be sufficient for 8k video frames
    // If you see the message below for a valid input stream: increase the limit
    if (max_size > 64 * 1024 * 1024) {
        ALOGE("bogus max input size: %zu", max_size);
        return ERROR_MALFORMED;
    }
    mGroup = new MediaBufferGroup;

    int32_t max_size;
    CHECK(mFormat->findInt32(kKeyMaxInputSize, &max_size));

    mGroup->add_buffer(new MediaBuffer(max_size));

    mSrcBuffer = new (std::nothrow) uint8_t[max_size];
    if (mSrcBuffer == NULL) {
        // file probably specified a bad max size
        delete mGroup;
        mGroup = NULL;
        return ERROR_MALFORMED;
    }