summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mathias Agopian <mathias@google.com> 2017-03-08 15:02:55 -0800
committer Mathias Agopian <mathias@google.com> 2017-03-08 15:02:55 -0800
commit10e9ab50517330d1972234b4c167d5467d01abbf (patch)
tree54d3f8bd51f1d792a3a1b00afad7649911adae9d
parent56a8f942731ad34a8e85a9a0fb84f1be2ead5541 (diff)
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
-rw-r--r--libs/gui/Surface.cpp4
-rw-r--r--opengl/libs/EGL/eglApi.cpp10
2 files changed, 14 insertions, 0 deletions
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp
index ad1984a507..a2e12f7735 100644
--- a/libs/gui/Surface.cpp
+++ b/libs/gui/Surface.cpp
@@ -836,6 +836,10 @@ int Surface::query(int what, int* value) const {
*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);
diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp
index e52713f8f6..aed27c8f58 100644
--- a/opengl/libs/EGL/eglApi.cpp
+++ b/opengl/libs/EGL/eglApi.cpp
@@ -478,6 +478,16 @@ EGLSurface eglCreateWindowSurface( EGLDisplay dpy, EGLConfig config,
if (dp) {
EGLDisplay iDpy = dp->disp.dpy;
+ if (!window) {
+ return setError(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE);
+ }
+
+ int value = 0;
+ window->query(window, NATIVE_WINDOW_IS_VALID, &value);
+ if (!value) {
+ return setError(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE);
+ }
+
int result = native_window_api_connect(window, NATIVE_WINDOW_API_EGL);
if (result != OK) {
ALOGE("eglCreateWindowSurface: native_window_api_connect (win=%p) "