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

Commit 94dcd2d4 authored by Santiago Seifert's avatar Santiago Seifert Committed by Android (Google) Code Review
Browse files

Merge "Fix buffer leak in MPEG4Extractor"

parents 54089e09 7df01786
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -6471,17 +6471,18 @@ media_status_t MPEG4Source::read(
        // Whole NAL units are returned but each fragment is prefixed by
        // the start code (0x00 00 00 01).
        ssize_t num_bytes_read = 0;
        if (mSrcBufferSize < size) {
        bool mSrcBufferFitsDataToRead = size <= mSrcBufferSize;
        if (mSrcBufferFitsDataToRead) {
          num_bytes_read = mDataSource->readAt(offset, mSrcBuffer, size);
        } else {
          // We are trying to read a sample larger than the expected max sample size.
          return AMEDIA_ERROR_MALFORMED;
          // Fall through and let the failure be handled by the following if.
        }
        num_bytes_read = mDataSource->readAt(offset, mSrcBuffer, size);

        if (num_bytes_read < (ssize_t)size) {
            mBuffer->release();
            mBuffer = NULL;

            return AMEDIA_ERROR_IO;
            return mSrcBufferFitsDataToRead ? AMEDIA_ERROR_IO : AMEDIA_ERROR_MALFORMED;
        }

        uint8_t *dstData = (uint8_t *)mBuffer->data();