libgui: Check result in hook_dequeueBuffer_DEPRECATED

Surface::hook_dequeueBuffer_DEPRECATED calls c->dequeueBuffer without
checking the returned result value.  It should check for failing
result and return on error without using the values that
c->dequeueBuffer did not set.

Bug: 28692406
Change-Id: I10f9a23ad1052c5149040124366e0eb91b616267
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp
index 6811269..9d130cd 100644
--- a/libs/gui/Surface.cpp
+++ b/libs/gui/Surface.cpp
@@ -162,6 +162,9 @@
     ANativeWindowBuffer* buf;
     int fenceFd = -1;
     int result = c->dequeueBuffer(&buf, &fenceFd);
+    if (result != OK) {
+        return result;
+    }
     sp<Fence> fence(new Fence(fenceFd));
     int waitResult = fence->waitForever("dequeueBuffer_DEPRECATED");
     if (waitResult != OK) {