OSDN Git Service

libvulkan: Only write vkCreateInstance out parameter on succes
authorJesse Hall <jessehall@google.com>
Mon, 18 Jan 2016 05:44:16 +0000 (21:44 -0800)
committerJesse Hall <jessehall@google.com>
Mon, 25 Jan 2016 21:49:31 +0000 (13:49 -0800)
Change-Id: If9f2924caa1c9da4d12eb2d4730e03ea4af0d113
(cherry picked from commit 7adb6e70a83be579e7059ca9fd3b1a2f25d58390)

vulkan/libvulkan/loader.cpp

index 5abd3c5..be0ce03 100644 (file)
@@ -1100,14 +1100,14 @@ VkResult CreateInstance_Top(const VkInstanceCreateInfo* create_info,
         }
     }
 
-    *instance_out = instance->handle;
+    VkInstance handle = instance->handle;
     PFN_vkCreateInstance create_instance =
         reinterpret_cast<PFN_vkCreateInstance>(
             next_get_proc_addr(instance->handle, "vkCreateInstance"));
-    result = create_instance(create_info, allocator, instance_out);
+    result = create_instance(create_info, allocator, &handle);
     if (enable_callback)
         FreeAllocatedCreateInfo(local_create_info, instance->alloc);
-    if (result <= 0) {
+    if (result < 0) {
         // For every layer, including the loader top and bottom layers:
         // - If a call to the next CreateInstance fails, the layer must clean
         //   up anything it has successfully done so far, and propagate the
@@ -1137,6 +1137,7 @@ VkResult CreateInstance_Top(const VkInstanceCreateInfo* create_info,
                                      allocator, &instance->message);
     }
 
+    *instance_out = instance->handle;
     return result;
 }