vulkan: detect errors in VkEnumerate*ExtensionProperties

Return VK_ERROR_LAYER_NOT_PRESENT when the layer is not available.

Change-Id: I9d9aafe6e40c2ca49e58bc7c70114d0f11de2f81
diff --git a/vulkan/libvulkan/api.cpp b/vulkan/libvulkan/api.cpp
index 3db625f..21a6c89 100644
--- a/vulkan/libvulkan/api.cpp
+++ b/vulkan/libvulkan/api.cpp
@@ -1131,16 +1131,13 @@
         return VK_ERROR_INITIALIZATION_FAILED;
 
     if (pLayerName) {
-        const VkExtensionProperties* props;
-        uint32_t count;
-
         const Layer* layer = FindLayer(pLayerName);
-        if (layer) {
-            props = GetLayerInstanceExtensions(*layer, count);
-        } else {
-            props = nullptr;
-            count = 0;
-        }
+        if (!layer)
+            return VK_ERROR_LAYER_NOT_PRESENT;
+
+        uint32_t count;
+        const VkExtensionProperties* props =
+            GetLayerInstanceExtensions(*layer, count);
 
         if (!pProperties || *pPropertyCount > count)
             *pPropertyCount = count;
@@ -1196,16 +1193,13 @@
     uint32_t* pPropertyCount,
     VkExtensionProperties* pProperties) {
     if (pLayerName) {
-        const VkExtensionProperties* props;
-        uint32_t count;
-
         const Layer* layer = FindLayer(pLayerName);
-        if (layer && IsLayerGlobal(*layer)) {
-            props = GetLayerDeviceExtensions(*layer, count);
-        } else {
-            props = nullptr;
-            count = 0;
-        }
+        if (!layer || !IsLayerGlobal(*layer))
+            return VK_ERROR_LAYER_NOT_PRESENT;
+
+        uint32_t count;
+        const VkExtensionProperties* props =
+            GetLayerDeviceExtensions(*layer, count);
 
         if (!pProperties || *pPropertyCount > count)
             *pPropertyCount = count;