OSDN Git Service

libvulkan: Really only write vkCreateInstance out parameter on success
authorJesse Hall <jessehall@google.com>
Mon, 18 Jan 2016 08:59:45 +0000 (00:59 -0800)
committerJesse Hall <jessehall@google.com>
Mon, 25 Jan 2016 21:49:31 +0000 (13:49 -0800)
Change-Id: I7efc7dba420565781f15610bbfa7dfd1be1cf84d
(cherry picked from commit 92707024c23b737cad16366ee7380a00e88a797e)

vulkan/libvulkan/loader.cpp

index ee1e9ac..68ca3c2 100644 (file)
@@ -1130,7 +1130,9 @@ VkResult CreateInstance_Top(const VkInstanceCreateInfo* create_info,
     result = create_instance(create_info, allocator, &handle);
     if (enable_callback)
         FreeAllocatedCreateInfo(local_create_info, instance->alloc);
-    if (result < 0) {
+    if (result >= 0) {
+        *instance_out = instance->handle;
+    } else {
         // 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
@@ -1160,7 +1162,6 @@ VkResult CreateInstance_Top(const VkInstanceCreateInfo* create_info,
                                      allocator, &instance->message);
     }
 
-    *instance_out = instance->handle;
     return result;
 }