aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Capens <capn@google.com>2018-03-13 10:54:18 -0400
committerNicolas Capens <nicolascapens@google.com>2018-03-13 15:28:18 +0000
commitf9b80fe143f8bf6e27203b43f4eb5c283222af70 (patch)
treea295de859a1072c3752379046aa2e750fcf38460
parenta124f042c3b49cf1917a070ff66c8b333f9d48d7 (diff)
downloadswiftshader-f9b80fe143f8bf6e27203b43f4eb5c283222af70.tar.gz
Check X11 return status.
We weren't checking the return status of an XGetWindowAttributes() call while checking for a resized window. It appears that it can start to fail possibly due to an out-of-memory situation or the window being destroyed before the EGL surface. Note that the EGL spec does not have a recommendation on how to handle this situation. Generating EGL_BAD_ALLOC is intended for eglCreate* call failures, while EGL_BAD_NATIVE_WINDOW appears to be reserved for calls that take a native window as a parameter. eglSwapBuffers is neither. Bug chromium:819481 Change-Id: I270730567b5179ee43b814e8bd017b601dfbe079 Reviewed-on: https://swiftshader-review.googlesource.com/17708 Tested-by: Nicolas Capens <nicolascapens@google.com> Reviewed-by: Alexis Hétu <sugoi@google.com>
-rw-r--r--src/OpenGL/libEGL/Display.cpp2
-rw-r--r--src/OpenGL/libEGL/Surface.cpp11
2 files changed, 10 insertions, 3 deletions
diff --git a/src/OpenGL/libEGL/Display.cpp b/src/OpenGL/libEGL/Display.cpp
index 9e56918dc..0e58125cb 100644
--- a/src/OpenGL/libEGL/Display.cpp
+++ b/src/OpenGL/libEGL/Display.cpp
@@ -567,7 +567,7 @@ bool Display::isValidWindow(EGLNativeWindowType window)
XWindowAttributes windowAttributes;
Status status = libX11->XGetWindowAttributes((::Display*)nativeDisplay, window, &windowAttributes);
- return status == True;
+ return status != 0;
}
return false;
#elif defined(__APPLE__)
diff --git a/src/OpenGL/libEGL/Surface.cpp b/src/OpenGL/libEGL/Surface.cpp
index 3d17cba63..d373990d4 100644
--- a/src/OpenGL/libEGL/Surface.cpp
+++ b/src/OpenGL/libEGL/Surface.cpp
@@ -269,7 +269,9 @@ bool WindowSurface::checkForResize()
{
#if defined(_WIN32)
RECT client;
- if(!GetClientRect(window, &client))
+ BOOL status = GetClientRect(window, &client);
+
+ if(status == 0)
{
return error(EGL_BAD_NATIVE_WINDOW, false);
}
@@ -281,7 +283,12 @@ bool WindowSurface::checkForResize()
int windowHeight; window->query(window, NATIVE_WINDOW_HEIGHT, &windowHeight);
#elif defined(__linux__)
XWindowAttributes windowAttributes;
- libX11->XGetWindowAttributes((::Display*)display->getNativeDisplay(), window, &windowAttributes);
+ Status status = libX11->XGetWindowAttributes((::Display*)display->getNativeDisplay(), window, &windowAttributes);
+
+ if(status == 0)
+ {
+ return error(EGL_BAD_NATIVE_WINDOW, false);
+ }
int windowWidth = windowAttributes.width;
int windowHeight = windowAttributes.height;