diff options
author | Francis Hart <fhart@nvidia.com> | 2014-10-31 10:06:18 +0200 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-01-28 10:38:06 -0800 |
commit | e7e6006bd5a09d54e730dc2e167f7808e767cc87 (patch) | |
tree | 71f5dd0b0edf9d1bdd23a71fc81f58af73427d19 | |
parent | ebbdb55300c64b1916f53ae837a870e3917b86e1 (diff) | |
download | android_frameworks_native-e7e6006bd5a09d54e730dc2e167f7808e767cc87.tar.gz android_frameworks_native-e7e6006bd5a09d54e730dc2e167f7808e767cc87.tar.bz2 android_frameworks_native-e7e6006bd5a09d54e730dc2e167f7808e767cc87.zip |
Surface: Always consume fence fd in queueBuffer
The API docs for the behaviour of ANativeWindow::queueBuffer state that
it always takes ownership of the fence fd parameter. The
Surface::queueBuffer implementation did not conform to this. If an error
occured within its queueBuffer function, then dependending what the
error was, the fence fd was either left untouched or closed.
This made it impossible for a client of ANativeWindow::queueBuffer to
correctly manage the fence fd if an error occured, resulting it either
an fd leak or a use-after-close scenario.
Change-Id: I3a8169709db3715dbcb3db258ef2056623e653f0
-rw-r--r-- | libs/gui/Surface.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp index b3c8943e1..72d9af314 100644 --- a/libs/gui/Surface.cpp +++ b/libs/gui/Surface.cpp @@ -318,6 +318,7 @@ int Surface::queueBuffer(android_native_buffer_t* buffer, int fenceFd) { Mutex::Autolock lock(mMutex); int64_t timestamp; bool isAutoTimestamp = false; + sp<Fence> fence(fenceFd >= 0 ? new Fence(fenceFd) : Fence::NO_FENCE); if (mTimestamp == NATIVE_WINDOW_TIMESTAMP_AUTO) { timestamp = systemTime(SYSTEM_TIME_MONOTONIC); isAutoTimestamp = true; @@ -345,7 +346,6 @@ int Surface::queueBuffer(android_native_buffer_t* buffer, int fenceFd) { } #endif - sp<Fence> fence(fenceFd >= 0 ? new Fence(fenceFd) : Fence::NO_FENCE); IGraphicBufferProducer::QueueBufferOutput output; IGraphicBufferProducer::QueueBufferInput input(timestamp, isAutoTimestamp, crop, #ifdef QCOM_BSP |