OSDN Git Service

libgui: fix BQ buffer allocation error checking
authorChia-I Wu <olv@google.com>
Thu, 25 May 2017 16:34:56 +0000 (09:34 -0700)
committerChia-I Wu <olv@google.com>
Thu, 25 May 2017 17:31:05 +0000 (10:31 -0700)
The error path was broken since we moved away from
IGraphicBufferAlloc.

Bug: 37956614
Test: simulate buffer allocation failures
Change-Id: I1e1ec840fafd3075b84126c6dbf6194568175a42

libs/gui/BufferQueueProducer.cpp

index 6a5593c..3d57769 100644 (file)
@@ -511,7 +511,7 @@ status_t BufferQueueProducer::dequeueBuffer(int *outSlot,
         { // Autolock scope
             Mutex::Autolock lock(mCore->mMutex);
 
-            if (graphicBuffer != NULL && !mCore->mIsAbandoned) {
+            if (error == NO_ERROR && !mCore->mIsAbandoned) {
                 graphicBuffer->setGenerationNumber(mCore->mGenerationNumber);
                 mSlots[*outSlot].mGraphicBuffer = graphicBuffer;
             }
@@ -519,7 +519,7 @@ status_t BufferQueueProducer::dequeueBuffer(int *outSlot,
             mCore->mIsAllocating = false;
             mCore->mIsAllocatingCondition.broadcast();
 
-            if (graphicBuffer == NULL) {
+            if (error != NO_ERROR) {
                 mCore->mFreeSlots.insert(*outSlot);
                 mCore->clearBufferSlotLocked(*outSlot);
                 BQ_LOGE("dequeueBuffer: createGraphicBuffer failed");