From 9bd8dd3b13a0d690c9316ed31be7c9a13f3f439f Mon Sep 17 00:00:00 2001 From: Jamie Gennis Date: Thu, 20 Sep 2012 11:43:43 -0700 Subject: [PATCH] ANW: fix an fd leak Change-Id: Id44cae6732c6694d2f470cbdfa5f59e7474f704f --- include/system/window.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/system/window.h b/include/system/window.h index 685e068fe..1e7f1143e 100644 --- a/include/system/window.h +++ b/include/system/window.h @@ -828,9 +828,8 @@ static inline int native_window_dequeue_buffer_and_wait(ANativeWindow *anw, int err = anw->dequeueBuffer(anw, anb, &fenceFd); if (err == 0 && fenceFd != -1) { err = sync_wait(fenceFd, UINT_MAX); - if (err == 0) { - close(fenceFd); - } else { + close(fenceFd); + if (err != 0) { anw->cancelBuffer(anw, *anb, fenceFd); *anb = NULL; }