Skip to content

Commit 0fdc7a4

Browse files
Contributorcharles-lunarg
authored andcommitted
loader: Propagate OOM from loader_add_to_ext_list in two call sites
loader_add_to_ext_list() returns VkResult and documents that VK_ERROR_OUT_OF_HOST_MEMORY signals allocation failure, but two call sites discarded the return value entirely: 1. loader_read_layer_json() – when appending an instance extension from a layer's JSON manifest the OOM path silently drops the extension and continues. The device-extension block directly below it correctly checks the analogous loader_add_to_dev_ext_list() return value; bring instance-extension parsing in line with it. 2. terminator_EnumerateInstanceExtensionProperties() – when merging implicit-layer extensions into the local list the return value was ignored. On allocation failure the function continues with an incomplete list and returns VK_SUCCESS to the application, violating the Vulkan spec guarantee that a successful count query returns the full set of available extensions. Capture the return value in both sites and propagate VK_ERROR_OUT_OF_HOST_MEMORY via the existing 'goto out' paths. Fixes: silent OOM swallowing in loader_read_layer_json Fixes: silent OOM swallowing in terminator_EnumerateInstanceExtensionProperties Reviewed-by: (pending)
1 parent 70e3d87 commit 0fdc7a4

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

loader/loader.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3018,7 +3018,8 @@ VkResult loader_read_layer_json(const struct loader_instance *inst, struct loade
30183018
loader_instance_heap_free(inst, spec_version);
30193019
bool ext_unsupported = wsi_unsupported_instance_extension(&ext_prop);
30203020
if (!ext_unsupported) {
3021-
loader_add_to_ext_list(inst, &props.instance_extension_list, 1, &ext_prop);
3021+
result = loader_add_to_ext_list(inst, &props.instance_extension_list, 1, &ext_prop);
3022+
if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
30223023
}
30233024
}
30243025
}
@@ -7617,7 +7618,10 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumerateInstanceExtensionProperties(c
76177618
}
76187619
for (uint32_t i = 0; i < instance_layers.count; i++) {
76197620
struct loader_extension_list *ext_list = &instance_layers.list[i].instance_extension_list;
7620-
loader_add_to_ext_list(NULL, &local_ext_list, ext_list->count, ext_list->list);
7621+
res = loader_add_to_ext_list(NULL, &local_ext_list, ext_list->count, ext_list->list);
7622+
if (VK_SUCCESS != res) {
7623+
goto out;
7624+
}
76217625
}
76227626

76237627
global_ext_list = &local_ext_list;

0 commit comments

Comments
 (0)