From a92b56e6455aa23a1b4dff8b1636506175243ea4 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 11 Jan 2023 16:04:49 -0500 Subject: Fix potential leak --- src/x11_vulkan.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/x11_vulkan.c b/src/x11_vulkan.c index 5b6745e..54b1218 100644 --- a/src/x11_vulkan.c +++ b/src/x11_vulkan.c @@ -36,15 +36,18 @@ puglNewVulkanLoader(PuglWorld* PUGL_UNUSED(world)) PuglVulkanLoader* const loader = (PuglVulkanLoader*)calloc(1, sizeof(PuglVulkanLoader)); - if (loader) { - loader->libvulkan = libvulkan; + if (!loader) { + dlclose(libvulkan); + return NULL; + } - loader->vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)dlsym( - loader->libvulkan, "vkGetInstanceProcAddr"); + loader->libvulkan = libvulkan; - loader->vkGetDeviceProcAddr = - (PFN_vkGetDeviceProcAddr)dlsym(loader->libvulkan, "vkGetDeviceProcAddr"); - } + loader->vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)dlsym( + loader->libvulkan, "vkGetInstanceProcAddr"); + + loader->vkGetDeviceProcAddr = + (PFN_vkGetDeviceProcAddr)dlsym(loader->libvulkan, "vkGetDeviceProcAddr"); return loader; } -- cgit v1.2.1