check that the NativeWindowType is valid in eglCreateWindowSurface
This will avoid certain crash (null dereference),
and return an error instead. This is useful for
app developers as java language apps are not
expected to crash when passed bad arguments
This doesn’t fix bug 36065206, but was prompted
by it.
Test: compile / run
Bug: 36065206
Change-Id: I90d25730b3dd292d756b4c38b51320a466fa6d48
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp
index ad1984a..a2e12f7 100644
--- a/libs/gui/Surface.cpp
+++ b/libs/gui/Surface.cpp
@@ -836,6 +836,10 @@
*value = mFrameTimestampsSupportsRetire ? 1 : 0;
return NO_ERROR;
}
+ case NATIVE_WINDOW_IS_VALID: {
+ *value = mGraphicBufferProducer != nullptr ? 1 : 0;
+ return NO_ERROR;
+ }
}
}
return mGraphicBufferProducer->query(what, value);