vulkan/wsi/x11: don't crash on null visual
authorArda Coskunses <acoskunses@gmail.com>
Thu, 22 Dec 2016 21:55:03 +0000 (14:55 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 22 Dec 2016 22:09:34 +0000 (14:09 -0800)
When application window closed unexpectedly due to
lost window visualtypes getting invlaid parameters
which is causing a crash. Necessary check is added
to prevent the crash.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Cc: "13.0" <mesa-stable@lists.freedesktop.org>
src/vulkan/wsi/wsi_common_x11.c

index 25ba0c1b8ae01dca05d46690dc89fe5ba6e58aef..037aa50ba2aa9c8cd674e08f4c67729e7d11db3a 100644 (file)
@@ -349,6 +349,9 @@ x11_surface_get_capabilities(VkIcdSurfaceBase *icd_surface,
    xcb_visualtype_t *visual =
       get_visualtype_for_window(conn, window, &visual_depth);
 
+   if (!visual)
+      return VK_ERROR_SURFACE_LOST_KHR;
+
    geom = xcb_get_geometry_reply(conn, geom_cookie, &err);
    if (geom) {
       VkExtent2D extent = { geom->width, geom->height };