loader: Fix bad memory ref and CreateInstance fail don't write ouptut
authorJon Ashburn <jon@lunarg.com>
Thu, 14 Jan 2016 20:51:55 +0000 (13:51 -0700)
committerJon Ashburn <jon@lunarg.com>
Thu, 14 Jan 2016 20:54:10 +0000 (13:54 -0700)
Gitlab #58
CreateInstance shouldn't update output parameter on failure.

loader/loader.c
loader/trampoline.c

index e0760bf..aeb83a9 100644 (file)
@@ -3214,7 +3214,6 @@ VKAPI_ATTR VkResult VKAPI_CALL loader_CreateInstance(
             {
                 ptr_instance->icds = ptr_instance->icds->next;
                 loader_icd_destroy(ptr_instance, icd);
-                icd->instance = VK_NULL_HANDLE;
                 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
                         "ICD ignored: failed to CreateInstance and find entrypoints with ICD");
             }
index c06e2cf..f46d40f 100644 (file)
@@ -181,17 +181,18 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(
     debug_report_create_instance(ptr_instance, pCreateInfo);
 
 
-    *pInstance = (VkInstance) ptr_instance;
+    res = ptr_instance->disp->CreateInstance(pCreateInfo, pAllocator, &ptr_instance);
 
-    res = ptr_instance->disp->CreateInstance(pCreateInfo, pAllocator, pInstance);
-
-    /*
-     * Finally have the layers in place and everyone has seen
-     * the CreateInstance command go by. This allows the layer's
-     * GetInstanceProcAddr functions to return valid extension functions
-     * if enabled.
-     */
-    loader_activate_instance_layer_extensions(ptr_instance, *pInstance);
+    if (res == VK_SUCCESS) {
+        *pInstance = (VkInstance) ptr_instance;
+        /*
+         * Finally have the layers in place and everyone has seen
+         * the CreateInstance command go by. This allows the layer's
+         * GetInstanceProcAddr functions to return valid extension functions
+         * if enabled.
+         */
+        loader_activate_instance_layer_extensions(ptr_instance, *pInstance);
+    }
     /* Remove temporary debug_report callback */
     util_DestroyDebugReportCallback(ptr_instance, instance_callback, pAllocator);