Skip to content

Commit bc0a957

Browse files
pdaniell-nvcharles-lunarg
authored andcommitted
loader: Fix another memory leak with use of realloc
This shows up in the dEQP-VK.api.device_init.create_instance_device_intentional_alloc_fail.basic Vulkan CTS test.
1 parent 8b5249c commit bc0a957

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

loader/loader.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,11 +445,13 @@ VkResult normalize_path(const struct loader_instance *inst, char **passed_in_pat
445445
// If path_len wasn't big enough, need to realloc and call again
446446
// actual_len doesn't include null terminator
447447
if (actual_len + 1 > path_len) {
448-
path = loader_instance_heap_realloc(inst, path, path_len, actual_len + 1, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
449-
if (NULL == path) {
448+
char *new_path = loader_instance_heap_realloc(inst, path, path_len, actual_len + 1, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
449+
if (NULL == new_path) {
450+
loader_instance_heap_free(inst, path);
450451
res = VK_ERROR_OUT_OF_HOST_MEMORY;
451452
goto out;
452453
}
454+
path = new_path;
453455
// store the updated allocation size (sans null terminator)
454456
path_len = actual_len + 1;
455457

0 commit comments

Comments
 (0)