Mesa (10.6): egl/x11: don't abort when creating a DRI2 drawable fails

Emil Velikov evelikov at kemper.freedesktop.org
Thu Aug 20 12:52:56 UTC 2015


Module: Mesa
Branch: 10.6
Commit: 16c65ec37f5554041fa3dd8238d435041ac38526
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=16c65ec37f5554041fa3dd8238d435041ac38526

Author: Frank Binns <frank.binns at imgtec.com>
Date:   Tue Aug  4 14:32:45 2015 +0100

egl/x11: don't abort when creating a DRI2 drawable fails

When calling either eglCreateWindowSurface or eglCreatePixmapSurface it
was possible for an application to be aborted as a result of it failing
to create a DRI2 drawable on the server. This could happen due to an
application passing in an invalid native drawable handle, for example.

v2: Handle the case where an error has been set on the connection

Cc: <mesa-stable at lists.freedesktop.org>
Signed-off-by: Frank Binns <frank.binns at imgtec.com>
Reviewed-by: Emil Velikov <emil.l.velikov at gmail.com>
(cherry picked from commit 9a4eae61c24858d69d731d63b141d2acaed40d69)

---

 src/egl/drivers/dri2/platform_x11.c |   20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c
index 809974b..66342c1 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -273,7 +273,25 @@ dri2_x11_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
    }
 
    if (dri2_dpy->dri2) {
-      xcb_dri2_create_drawable (dri2_dpy->conn, dri2_surf->drawable);
+      xcb_void_cookie_t cookie;
+      int conn_error;
+
+      cookie = xcb_dri2_create_drawable_checked(dri2_dpy->conn,
+                                                dri2_surf->drawable);
+      error = xcb_request_check(dri2_dpy->conn, cookie);
+      conn_error = xcb_connection_has_error(dri2_dpy->conn);
+      if (conn_error || error != NULL) {
+         if (type == EGL_PBUFFER_BIT || conn_error || error->error_code == BadAlloc)
+            _eglError(EGL_BAD_ALLOC, "xcb_dri2_create_drawable_checked");
+         else if (type == EGL_WINDOW_BIT)
+            _eglError(EGL_BAD_NATIVE_WINDOW,
+                      "xcb_dri2_create_drawable_checked");
+         else
+            _eglError(EGL_BAD_NATIVE_PIXMAP,
+                      "xcb_dri2_create_drawable_checked");
+         free(error);
+         goto cleanup_dri_drawable;
+      }
    } else {
       if (type == EGL_PBUFFER_BIT) {
          dri2_surf->depth = _eglGetConfigKey(conf, EGL_BUFFER_SIZE);




More information about the mesa-commit mailing list