From eae8f032db504187079fe3ae3fa56990593cd857 Mon Sep 17 00:00:00 2001
From: Brendan King <Brendan.King@imgtec.com>
Date: Mon, 21 Jun 2021 17:05:17 +0100
Subject: [PATCH] vulkan/wsi: check the DRI3 and Present XCB reply pointers

Check that the DRI3 and Present version replies are not NULL
before accessing the version fields.

---
 src/vulkan/wsi/wsi_common_x11.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c
index 9dce78e..9eb624d 100644
--- a/src/vulkan/wsi/wsi_common_x11.c
+++ b/src/vulkan/wsi/wsi_common_x11.c
@@ -216,7 +216,7 @@ wsi_x11_connection_create(struct wsi_device *wsi_dev,
 
       ver_cookie = xcb_dri3_query_version(conn, 1, 2);
       ver_reply = xcb_dri3_query_version_reply(conn, ver_cookie, NULL);
-      has_dri3_v1_2 =
+      has_dri3_v1_2 = ver_reply != NULL &&
          (ver_reply->major_version > 1 || ver_reply->minor_version >= 2);
       free(ver_reply);
    }
@@ -230,7 +230,7 @@ wsi_x11_connection_create(struct wsi_device *wsi_dev,
 
       ver_cookie = xcb_present_query_version(conn, 1, 2);
       ver_reply = xcb_present_query_version_reply(conn, ver_cookie, NULL);
-      has_present_v1_2 =
+      has_present_v1_2 = ver_reply != NULL &&
         (ver_reply->major_version > 1 || ver_reply->minor_version >= 2);
       free(ver_reply);
    }
