From 94671be428212d87e3c781a248e373ef8e2bfa73 Mon Sep 17 00:00:00 2001 From: Yeongjin Jeong Date: Fri, 9 Aug 2019 18:43:06 +0900 Subject: [PATCH] vulkan/xcb: Don't try to create xcb window with non-xcb display 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 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/vulkan/xcb/gstvkwindow_xcb.c b/gst-libs/gst/vulkan/xcb/gstvkwindow_xcb.c index 047c276..fb32e97 100644 --- a/gst-libs/gst/vulkan/xcb/gstvkwindow_xcb.c +++ b/gst-libs/gst/vulkan/xcb/gstvkwindow_xcb.c @@ -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, -- 2.7.4