diff options
author | Jiwen 'Steve' Cai <jwcai@google.com> | 2017-06-02 15:23:26 -0700 |
---|---|---|
committer | Jiwen Cai <jiwen@google.com> | 2017-06-07 17:04:45 +0000 |
commit | ae6955fda8c669efdfd9cc9c3ff6b072db6e7c94 (patch) | |
tree | ff67c29c0ad7664169c515dbbe93be79826369bc | |
parent | 9351f72049a2bc65170afcf131008c8bd1710959 (diff) | |
download | native-ae6955fda8c669efdfd9cc9c3ff6b072db6e7c94.tar.gz |
No crash from AHardwareBuffer_unlock on NULL fence
The API document states: "If fence is not NULL then it will be set to a
file descriptor that is signaled when all pending work on the buffer is
completed." As it's too late to change the document, we should probably
update the implement and use GraphicsBuffer::unlock under the hood.
Bug: 62302267
Test: Build, AHardware CTS
Change-Id: Ic0fac5d7addfba67baaa1b5d7c221fc25d02df56
(cherry picked from commit 6cdbb537105b663572e71afe06bde1164fc215f3)
-rw-r--r-- | libs/nativewindow/AHardwareBuffer.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libs/nativewindow/AHardwareBuffer.cpp b/libs/nativewindow/AHardwareBuffer.cpp index c0602e7417..2f4b996c75 100644 --- a/libs/nativewindow/AHardwareBuffer.cpp +++ b/libs/nativewindow/AHardwareBuffer.cpp @@ -134,7 +134,10 @@ int AHardwareBuffer_unlock(AHardwareBuffer* buffer, int32_t* fence) { if (!buffer) return BAD_VALUE; GraphicBuffer* gBuffer = AHardwareBuffer_to_GraphicBuffer(buffer); - return gBuffer->unlockAsync(fence); + if (fence == nullptr) + return gBuffer->unlock(); + else + return gBuffer->unlockAsync(fence); } int AHardwareBuffer_sendHandleToUnixSocket(const AHardwareBuffer* buffer, int socketFd) { |