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

Commit fc609407 authored by Pawin Vongmasa's avatar Pawin Vongmasa
Browse files

Check the buffer index from acquireBuffer

Test: Run the POC
Test: Small CtsMediaTestCases
Bug: 37563942
Merged-In: I8ddfbc91a08d96de1f732e6776d6f90997042f6b
Change-Id: I8ddfbc91a08d96de1f732e6776d6f90997042f6b
parent 5136b743
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -346,6 +346,12 @@ void GraphicBufferSource::suspend(bool suspend) {
            } else if (err != OK) {
                ALOGW("suspend: acquireBuffer returned err=%d", err);
                break;
            } else if (item.mBuf < 0 ||
                    item.mBuf >= BufferQueue::NUM_BUFFER_SLOTS) {
                // Invalid buffer index
                ALOGW("suspend: corrupted buffer index (%d)",
                        item.mBuf);
                break;
            }

            --mNumFramesAvailable;
@@ -396,6 +402,10 @@ bool GraphicBufferSource::fillCodecBuffer_l() {
        // now what? fake end-of-stream?
        ALOGW("fillCodecBuffer_l: acquireBuffer returned err=%d", err);
        return false;
    } else if (item.mBuf < 0 || item.mBuf >= BufferQueue::NUM_BUFFER_SLOTS) {
        // Invalid buffer index
        ALOGW("fillCodecBuffer_l: corrupted buffer index (%d)", item.mBuf);
        return false;
    }

    mNumFramesAvailable--;
@@ -696,10 +706,17 @@ void GraphicBufferSource::onFrameAvailable() {
        BufferQueue::BufferItem item;
        status_t err = mBufferQueue->acquireBuffer(&item, 0);
        if (err == OK) {
            if (item.mBuf < 0 ||
                    item.mBuf >= BufferQueue::NUM_BUFFER_SLOTS) {
                // Invalid buffer index
                ALOGW("onFrameAvailable: corrupted buffer index (%d)",
                        item.mBuf);
                return;
            }
            // If this is the first time we're seeing this buffer, add it to our
            // slot table.
            if (item.mGraphicBuffer != NULL) {
                ALOGV("fillCodecBuffer_l: setting mBufferSlot %d", item.mBuf);
                ALOGV("onFrameAvailable: setting mBufferSlot %d", item.mBuf);
                mBufferSlot[item.mBuf] = item.mGraphicBuffer;
            }
            mBufferQueue->releaseBuffer(item.mBuf, item.mFrameNumber,