From d7700a7af813af60e1dd6dcdaebad9b37c7ef771 Mon Sep 17 00:00:00 2001 From: Jon Ashburn Date: Thu, 14 Jan 2016 13:51:55 -0700 Subject: loader: Fix bad memory ref and CreateInstance fail don't write ouptut Gitlab #58 CreateInstance shouldn't update output parameter on failure. --- loader/trampoline.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'loader/trampoline.c') diff --git a/loader/trampoline.c b/loader/trampoline.c index c06e2cf5..f46d40f7 100644 --- a/loader/trampoline.c +++ b/loader/trampoline.c @@ -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); -- cgit v1.2.3