vulkan/xcb: Don't try to create xcb window with non-xcb display
authorYeongjin Jeong <yeongjin.jeong@navercorp.com>
Fri, 9 Aug 2019 09:43:06 +0000 (18:43 +0900)
committerMatthew Waters <matthew@centricular.com>
Thu, 29 Aug 2019 11:19:37 +0000 (11:19 +0000)
Non-xcb display does not have a xcb_connection and trying
to create xcb window with wild pointer can cause segfault.

gst-libs/gst/vulkan/xcb/gstvkwindow_xcb.c

index 047c276..fb32e97 100644 (file)
@@ -271,9 +271,17 @@ static gboolean
 gst_vulkan_window_xcb_open (GstVulkanWindow * window, GError ** error)
 {
   GstVulkanWindowXCB *window_xcb = GST_VULKAN_WINDOW_XCB (window);
-  GstVulkanDisplayXCB *display_xcb = (GstVulkanDisplayXCB *) window->display;
+  GstVulkanDisplayXCB *display_xcb;
   xcb_connection_t *connection;
 
+  if (!GST_IS_VULKAN_DISPLAY_XCB (window->display)) {
+    g_set_error (error, GST_VULKAN_WINDOW_ERROR,
+        GST_VULKAN_WINDOW_ERROR_RESOURCE_UNAVAILABLE,
+        "Cannot create an XCB window from a non-XCB display");
+    goto failure;
+  }
+
+  display_xcb = GST_VULKAN_DISPLAY_XCB (window->display);
   connection = GST_VULKAN_DISPLAY_XCB_CONNECTION (display_xcb);
   if (connection == NULL) {
     g_set_error (error, GST_VULKAN_WINDOW_ERROR,