Fix preloaded icd's being freed with custom allocators
authorCharles Giessen <charles@lunarg.com>
Wed, 12 Jun 2024 21:44:26 +0000 (16:44 -0500)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Thu, 13 Jun 2024 15:42:09 +0000 (10:42 -0500)
During unloading of unused drivers, the loader checks for the driver in its
list of preloaded ICD's, and removes it if it is in it. If the user provided
a custom callback during instance creation, this was being used during this
unloading, which is wrong because preloaded icd's weren't allocated with the
custom allocator in the first place.

loader/loader.c

index 6bcefcd7d2ae24f39243304ee7227ee9cef22670..b9f7195de756ce8b250de6990f14d4b7b26dec0e 100644 (file)
@@ -6529,7 +6529,7 @@ void unload_drivers_without_physical_devices(struct loader_instance *inst) {
                     for (uint32_t i = 0; i < preloaded_icds.count; i++) {
                         if (NULL != preloaded_icds.scanned_list[i].lib_name && NULL != scanned_icd_to_remove->lib_name &&
                             strcmp(preloaded_icds.scanned_list[i].lib_name, scanned_icd_to_remove->lib_name) == 0) {
-                            loader_unload_scanned_icd(inst, &preloaded_icds.scanned_list[i]);
+                            loader_unload_scanned_icd(NULL, &preloaded_icds.scanned_list[i]);
                             // condense the list so that it doesn't contain empty elements.
                             if (i < preloaded_icds.count - 1) {
                                 memcpy((void *)&preloaded_icds.scanned_list[i],