From 1dbf0e3b2fd19581657ec4e7fadb93a5b81f297e Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 7 Feb 2018 14:40:08 -0800 Subject: libgui: fix a race in BufferQueueProducer::allocateBuffers Bug: 72902195 Test: boots Change-Id: I2edb2420c1b909ed91ccae8179fc413b6828d2cb --- libs/gui/BufferQueueProducer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libs/gui/BufferQueueProducer.cpp') diff --git a/libs/gui/BufferQueueProducer.cpp b/libs/gui/BufferQueueProducer.cpp index e583b40632..1e8d94c30b 100644 --- a/libs/gui/BufferQueueProducer.cpp +++ b/libs/gui/BufferQueueProducer.cpp @@ -1331,6 +1331,7 @@ void BufferQueueProducer::allocateBuffers(uint32_t width, uint32_t height, uint32_t allocHeight = 0; PixelFormat allocFormat = PIXEL_FORMAT_UNKNOWN; uint64_t allocUsage = 0; + std::string allocName; { // Autolock scope Mutex::Autolock lock(mCore->mMutex); mCore->waitWhileAllocatingLocked(); @@ -1350,6 +1351,7 @@ void BufferQueueProducer::allocateBuffers(uint32_t width, uint32_t height, allocHeight = height > 0 ? height : mCore->mDefaultHeight; allocFormat = format != 0 ? format : mCore->mDefaultBufferFormat; allocUsage = usage | mCore->mConsumerUsageBits; + allocName.assign(mCore->mConsumerName.string(), mCore->mConsumerName.size()); mCore->mIsAllocating = true; } // Autolock scope @@ -1358,7 +1360,7 @@ void BufferQueueProducer::allocateBuffers(uint32_t width, uint32_t height, for (size_t i = 0; i < newBufferCount; ++i) { sp graphicBuffer = new GraphicBuffer( allocWidth, allocHeight, allocFormat, BQ_LAYER_COUNT, - allocUsage, {mConsumerName.string(), mConsumerName.size()}); + allocUsage, allocName); status_t result = graphicBuffer->initCheck(); -- cgit v1.2.3-59-g8ed1b