From a0aeedc3baefdb4c5150a48ed669f063bff8aa8c Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Mon, 20 Apr 2020 15:09:35 -0700 Subject: BufferQueueProducer: Slot may have null buffer [2/2]. I'm not entirely sure how we got in to this state but it seems best not to crash. It seems like we are tearing down and everything will work out in the end anyway. This contains the fix to cancelBuffer that was supposed to be in the first CL. Bug: 153913134 Test: Existing tests pass Change-Id: Ie6f17d43e044e18be03e6c477ca8bc0495cee0a1 --- libs/gui/BufferQueueProducer.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'libs/gui/BufferQueueProducer.cpp') diff --git a/libs/gui/BufferQueueProducer.cpp b/libs/gui/BufferQueueProducer.cpp index 3f4c5da193..26784cf14e 100644 --- a/libs/gui/BufferQueueProducer.cpp +++ b/libs/gui/BufferQueueProducer.cpp @@ -1120,8 +1120,9 @@ status_t BufferQueueProducer::cancelBuffer(int slot, const sp& fence) { mCore->mFreeBuffers.push_back(slot); } - if (mCore->mConsumerListener != nullptr) { - mCore->mConsumerListener->onFrameCancelled(mSlots[slot].mGraphicBuffer->getId()); + auto gb = mSlots[slot].mGraphicBuffer; + if (mCore->mConsumerListener != nullptr && gb != nullptr) { + mCore->mConsumerListener->onFrameCancelled(gb->getId()); } mSlots[slot].mFence = fence; mCore->mDequeueCondition.notify_all(); -- cgit v1.2.3-59-g8ed1b