fix [2170283] SurfaceFlinger crashes on OOM.
when running out of memory, a null handle is returned but the error code may not be set.
In that case we need to return NO_MEMORY instead of NO_ERROR, so that the calling code
won't try to dereference the null pointer.
diff --git a/libs/ui/Surface.cpp b/libs/ui/Surface.cpp
index 2d83a8c..f51ca7a 100644
--- a/libs/ui/Surface.cpp
+++ b/libs/ui/Surface.cpp
@@ -746,6 +746,8 @@
currentBuffer->setIndex(index);
mNeedFullUpdate = true;
}
+ } else {
+ err = err<0 ? err : NO_MEMORY;
}
}
return err;