diff options
| author | 2018-02-07 14:40:08 -0800 | |
|---|---|---|
| committer | 2018-02-07 14:51:32 -0800 | |
| commit | 1dbf0e3b2fd19581657ec4e7fadb93a5b81f297e (patch) | |
| tree | 4022c1abcdb24a1889367280cb67ad224e2f589f /libs/gui/BufferQueueProducer.cpp | |
| parent | 989fc50a1a52c57c218c9ccc681847c6c120d892 (diff) | |
libgui: fix a race in BufferQueueProducer::allocateBuffers
Bug: 72902195
Test: boots
Change-Id: I2edb2420c1b909ed91ccae8179fc413b6828d2cb
Diffstat (limited to 'libs/gui/BufferQueueProducer.cpp')
| -rw-r--r-- | libs/gui/BufferQueueProducer.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
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> graphicBuffer = new GraphicBuffer( allocWidth, allocHeight, allocFormat, BQ_LAYER_COUNT, - allocUsage, {mConsumerName.string(), mConsumerName.size()}); + allocUsage, allocName); status_t result = graphicBuffer->initCheck(); |