libvulkan: Only write vkCreateInstance out parameter on succes

Change-Id: If9f2924caa1c9da4d12eb2d4730e03ea4af0d113
(cherry picked from commit 7adb6e70a83be579e7059ca9fd3b1a2f25d58390)
diff --git a/vulkan/libvulkan/loader.cpp b/vulkan/libvulkan/loader.cpp
index 5abd3c5..be0ce03 100644
--- a/vulkan/libvulkan/loader.cpp
+++ b/vulkan/libvulkan/loader.cpp
@@ -1100,14 +1100,14 @@
         }
     }
 
-    *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 @@
                                      allocator, &instance->message);
     }
 
+    *instance_out = instance->handle;
     return result;
 }