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

Commit 54f81e8f authored by Pawin Vongmasa's avatar Pawin Vongmasa Committed by android-build-merger
Browse files

Merge "Check the buffer index from acquireBuffer" into klp-dev am: d0509021

am: 668b7f4b

Change-Id: I9d59a91f2a63115978bc48087a721cd7e6d8facb
parents 1f44782e 668b7f4b
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,