OSDN Git Service

Surface: Initialize variable and add a defensive check
authorRama Vaddula <rvaddula@codeaurora.org>
Thu, 12 Sep 2013 21:09:32 +0000 (14:09 -0700)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Mon, 3 Feb 2014 14:26:15 +0000 (22:26 +0800)
Initialize buf variable and make sure to check for return
value of dequeueBuffer() before sending to the client.

Change-Id: I0569f2d45825fab0e5d0f38fc91a07990f57c7ab
(cherry picked from commit a6bd7106a7305208f187fbf0a48f14139e33c9d6)
(cherry picked from commit e5d7662d68c5be2b282edd58d4feb68a4d476182)
(cherry picked from commit 885c146144480d4371a0a97df89b8e77f53d3d94)

libs/gui/Surface.cpp

index 2260754..f03c473 100644 (file)
@@ -112,9 +112,12 @@ int Surface::hook_queueBuffer(ANativeWindow* window,
 int Surface::hook_dequeueBuffer_DEPRECATED(ANativeWindow* window,
         ANativeWindowBuffer** buffer) {
     Surface* c = getSelf(window);
-    ANativeWindowBuffer* buf;
+    ANativeWindowBuffer* buf = NULL;
     int fenceFd = -1;
     int result = c->dequeueBuffer(&buf, &fenceFd);
+
+    if (result != NO_ERROR) return result;
+
     sp<Fence> fence(new Fence(fenceFd));
     int waitResult = fence->waitForever("dequeueBuffer_DEPRECATED");
     if (waitResult != OK) {