summaryrefslogtreecommitdiff
path: root/loader
diff options
context:
space:
mode:
authorMark Young <marky@lunarg.com>2017-03-09 14:17:40 -0700
committerMark Young <marky@lunarg.com>2017-03-09 14:31:21 -0700
commit0ee200198a7f12979e0cb51019775423330df44b (patch)
tree637e7c568bf51ee96178d6e5312db02256a66ec7 /loader
parent60dc418bdc8ca3000f254c2a8940cf73d9b42bce (diff)
loader: Set pointer to NULL
Cleanup enabled extension array pointer passed down to driver. If the loader overrode the create info struct, the pointer could be garbage if the enabled extension count was 0. Now, make sure it is NULL. Change-Id: I558d768e786892e7afc44f58b4173a2b8db3deee
Diffstat (limited to 'loader')
-rw-r--r--loader/loader.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/loader/loader.c b/loader/loader.c
index 639e764a..9f1a8063 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -4516,17 +4516,18 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDevice(VkPhysicalDevice physical
memcpy(&localCreateInfo, pCreateInfo, sizeof(localCreateInfo));
// NOTE: Need to filter the extensions to only those supported by the ICD.
- // No ICD will advertise support for layers. An ICD library could
- // support a layer, but it would be independent of the actual ICD,
- // just in the same library.
+ // No ICD will advertise support for layers. An ICD library could support a layer,
+ // but it would be independent of the actual ICD, just in the same library.
char **filtered_extension_names = NULL;
- filtered_extension_names = loader_stack_alloc(pCreateInfo->enabledExtensionCount * sizeof(char *));
- if (NULL == filtered_extension_names) {
- loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
- "terminator_CreateDevice: Failed to create extension name "
- "storage for %d extensions %d",
- pCreateInfo->enabledExtensionCount);
- return VK_ERROR_OUT_OF_HOST_MEMORY;
+ if (0 < pCreateInfo->enabledExtensionCount) {
+ filtered_extension_names = loader_stack_alloc(pCreateInfo->enabledExtensionCount * sizeof(char *));
+ if (NULL == filtered_extension_names) {
+ loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
+ "terminator_CreateDevice: Failed to create extension name "
+ "storage for %d extensions %d",
+ pCreateInfo->enabledExtensionCount);
+ return VK_ERROR_OUT_OF_HOST_MEMORY;
+ }
}
localCreateInfo.enabledLayerCount = 0;