aboutsummaryrefslogtreecommitdiff
path: root/loader/loader.c
diff options
context:
space:
mode:
authorMark Young <marky@lunarg.com>2017-06-26 14:03:08 -0600
committerMark Young <marky@lunarg.com>2017-06-26 14:20:52 -0600
commitd80f2f8b8c29f9c96f2ab3a54f0420e96bb83dcd (patch)
tree43f314b448aeace8b4e38e69a8170423c2eee0c2 /loader/loader.c
parent102588ce85c480264467ccc509fa793ed7e2f230 (diff)
downloadusermoji-d80f2f8b8c29f9c96f2ab3a54f0420e96bb83dcd.tar.xz
loader: Fix handling of JSON
If a JSON layer manifest file says it contained device extensions but didn't provide a list, or the list was malformed, it caused issues. Change-Id: I94b97b190aca35f9464918eb7195486566becaa0
Diffstat (limited to 'loader/loader.c')
-rw-r--r--loader/loader.c50
1 files changed, 27 insertions, 23 deletions
diff --git a/loader/loader.c b/loader/loader.c
index de57f5f0..05183b3f 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -912,33 +912,37 @@ VkResult loader_add_to_dev_ext_list(const struct loader_instance *inst, struct l
memcpy(&ext_list->list[idx].props, props, sizeof(*props));
ext_list->list[idx].entrypoint_count = entry_count;
- ext_list->list[idx].entrypoints =
- loader_instance_heap_alloc(inst, sizeof(char *) * entry_count, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
- if (ext_list->list[idx].entrypoints == NULL) {
- loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
- "loader_add_to_dev_ext_list: Failed to allocate space "
- "for device extension entrypoint list in list %d",
- idx);
- ext_list->list[idx].entrypoint_count = 0;
- return VK_ERROR_OUT_OF_HOST_MEMORY;
- }
- for (uint32_t i = 0; i < entry_count; i++) {
- ext_list->list[idx].entrypoints[i] =
- loader_instance_heap_alloc(inst, strlen(entrys[i]) + 1, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
- if (ext_list->list[idx].entrypoints[i] == NULL) {
- for (uint32_t j = 0; j < i; j++) {
- loader_instance_heap_free(inst, ext_list->list[idx].entrypoints[j]);
- }
- loader_instance_heap_free(inst, ext_list->list[idx].entrypoints);
- ext_list->list[idx].entrypoint_count = 0;
- ext_list->list[idx].entrypoints = NULL;
+ if (entry_count == 0) {
+ ext_list->list[idx].entrypoints = NULL;
+ } else {
+ ext_list->list[idx].entrypoints =
+ loader_instance_heap_alloc(inst, sizeof(char *) * entry_count, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
+ if (ext_list->list[idx].entrypoints == NULL) {
loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
"loader_add_to_dev_ext_list: Failed to allocate space "
- "for device extension entrypoint %d name",
- i);
+ "for device extension entrypoint list in list %d",
+ idx);
+ ext_list->list[idx].entrypoint_count = 0;
return VK_ERROR_OUT_OF_HOST_MEMORY;
}
- strcpy(ext_list->list[idx].entrypoints[i], entrys[i]);
+ for (uint32_t i = 0; i < entry_count; i++) {
+ ext_list->list[idx].entrypoints[i] =
+ loader_instance_heap_alloc(inst, strlen(entrys[i]) + 1, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
+ if (ext_list->list[idx].entrypoints[i] == NULL) {
+ for (uint32_t j = 0; j < i; j++) {
+ loader_instance_heap_free(inst, ext_list->list[idx].entrypoints[j]);
+ }
+ loader_instance_heap_free(inst, ext_list->list[idx].entrypoints);
+ ext_list->list[idx].entrypoint_count = 0;
+ ext_list->list[idx].entrypoints = NULL;
+ loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
+ "loader_add_to_dev_ext_list: Failed to allocate space "
+ "for device extension entrypoint %d name",
+ i);
+ return VK_ERROR_OUT_OF_HOST_MEMORY;
+ }
+ strcpy(ext_list->list[idx].entrypoints[i], entrys[i]);
+ }
}
ext_list->count++;