summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2017-11-30 14:48:15 +0100
committerAlexander Larsson <alexl@redhat.com>2017-11-30 21:57:42 +0100
commitf5e0986230f0cefc76208b0c2eea1bace5e6c37c (patch)
tree9b8ef6e9139b5db32b738dcb53b3bb735f201321
parentc30073793edcf373abf4fe31d6b51ec921bd2016 (diff)
downloadgtk+-f5e0986230f0cefc76208b0c2eea1bace5e6c37c.tar.gz
vulkan: Don't crash if vkEnumeratePhysicalDevices fails
-rw-r--r--gdk/gdkvulkancontext.c8
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;