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) {