fix: add dev pointer checking
authorDanny Zhu <danny@netflt.com>
Sat, 22 Oct 2022 03:06:31 +0000 (11:06 +0800)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Tue, 25 Oct 2022 15:08:22 +0000 (09:08 -0600)
loader/generated/vk_loader_extensions.c
loader/loader.c

index 1a16c82..5cdd307 100644 (file)
@@ -9536,11 +9536,6 @@ void extensions_create_instance(struct loader_instance *ptr_instance, const VkIn
 PFN_vkVoidFunction get_extension_device_proc_terminator(struct loader_device *dev, const char *pName) {
     PFN_vkVoidFunction addr = NULL;
 
-    if (dev == NULL)
-    {
-        return addr;
-    }
-    
     // ---- VK_KHR_swapchain extension commands
     if (dev->extensions.khr_swapchain_enabled) {
         if(!strcmp(pName, "vkCreateSwapchainKHR")) {
index 373c2b4..84031df 100644 (file)
@@ -192,7 +192,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkSetDeviceDispatch(VkDevice device, void *object
     struct loader_device *dev;
     struct loader_icd_term *icd_term = loader_get_icd_and_device(device, &dev, NULL);
 
-    if (NULL == icd_term) {
+    if (NULL == icd_term || NULL == dev) {
         return VK_ERROR_INITIALIZATION_FAILED;
     }
     loader_set_dispatch(object, &dev->loader_dispatch);
@@ -3951,9 +3951,11 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL loader_gpa_device_terminator(VkDevice d
     // object before passing the appropriate info along to the ICD.
     // This is why we also have to override the direct ICD call to
     // vkGetDeviceProcAddr to intercept those calls.
-    PFN_vkVoidFunction addr = get_extension_device_proc_terminator(dev, pName);
-    if (NULL != addr) {
-        return addr;
+    if(NULL != dev) {
+        PFN_vkVoidFunction addr = get_extension_device_proc_terminator(dev, pName);
+        if (NULL != addr) {
+            return addr;
+        }
     }
 
     return icd_term->dispatch.GetDeviceProcAddr(device, pName);