diff options
author | Alexander Larsson <alexl@redhat.com> | 2017-11-30 14:48:15 +0100 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2017-11-30 21:57:42 +0100 |
commit | f5e0986230f0cefc76208b0c2eea1bace5e6c37c (patch) | |
tree | 9b8ef6e9139b5db32b738dcb53b3bb735f201321 /gdk | |
parent | c30073793edcf373abf4fe31d6b51ec921bd2016 (diff) | |
download | gtk+-f5e0986230f0cefc76208b0c2eea1bace5e6c37c.tar.gz |
vulkan: Don't crash if vkEnumeratePhysicalDevices fails
Diffstat (limited to 'gdk')
-rw-r--r-- | gdk/gdkvulkancontext.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/gdk/gdkvulkancontext.c b/gdk/gdkvulkancontext.c index f44253479e..3fd697a8af 100644 --- a/gdk/gdkvulkancontext.c +++ b/gdk/gdkvulkancontext.c @@ -599,10 +599,9 @@ gdk_display_create_vulkan_device (GdkDisplay *display, { uint32_t i, j; - uint32_t n_devices; + uint32_t n_devices = 0; GDK_VK_CHECK(vkEnumeratePhysicalDevices, display->vk_instance, &n_devices, NULL); - VkPhysicalDevice *devices = g_newa (VkPhysicalDevice, n_devices); - GDK_VK_CHECK(vkEnumeratePhysicalDevices, display->vk_instance, &n_devices, devices); + VkPhysicalDevice *devices; if (n_devices == 0) { @@ -612,6 +611,9 @@ gdk_display_create_vulkan_device (GdkDisplay *display, return FALSE; } + devices = g_newa (VkPhysicalDevice, n_devices); + GDK_VK_CHECK(vkEnumeratePhysicalDevices, display->vk_instance, &n_devices, devices); + for (i = 0; i < n_devices; i++) { VkPhysicalDeviceProperties props; |