@@ -817,12 +817,13 @@ VkResult enumerate_adapter_physical_devices(struct loader_instance *inst, struct
817817
818818 // Get the actual physical devices
819819 do {
820- next_icd_phys_devs -> physical_devices = loader_instance_heap_realloc (
821- inst , next_icd_phys_devs -> physical_devices , next_icd_phys_devs -> device_count * sizeof (VkPhysicalDevice ),
822- count * sizeof (VkPhysicalDevice ), VK_SYSTEM_ALLOCATION_SCOPE_COMMAND );
823- if (next_icd_phys_devs -> physical_devices == NULL ) {
820+ void * new_ptr = loader_instance_heap_realloc (inst , next_icd_phys_devs -> physical_devices ,
821+ next_icd_phys_devs -> device_count * sizeof (VkPhysicalDevice ),
822+ count * sizeof (VkPhysicalDevice ), VK_SYSTEM_ALLOCATION_SCOPE_COMMAND );
823+ if (new_ptr == NULL ) {
824824 return VK_ERROR_OUT_OF_HOST_MEMORY ;
825825 }
826+ next_icd_phys_devs -> physical_devices = new_ptr ;
826827 next_icd_phys_devs -> device_count = count ;
827828 } while ((res = icd_term -> scanned_icd -> EnumerateAdapterPhysicalDevices (icd_term -> instance , luid , & count ,
828829 next_icd_phys_devs -> physical_devices )) == VK_INCOMPLETE );
@@ -978,13 +979,14 @@ VkResult windows_read_sorted_physical_devices(struct loader_instance *inst, uint
978979
979980 if (icd_phys_devs_array_size <= * icd_phys_devs_array_count ) {
980981 uint32_t old_size = icd_phys_devs_array_size * sizeof (struct loader_icd_physical_devices );
981- * icd_phys_devs_array = loader_instance_heap_realloc (inst , * icd_phys_devs_array , old_size , 2 * old_size ,
982- VK_SYSTEM_ALLOCATION_SCOPE_COMMAND );
982+ void * new_ptr = loader_instance_heap_realloc (inst , * icd_phys_devs_array , old_size , 2 * old_size ,
983+ VK_SYSTEM_ALLOCATION_SCOPE_COMMAND );
983984 if (* icd_phys_devs_array == NULL ) {
984985 adapter -> lpVtbl -> Release (adapter );
985986 res = VK_ERROR_OUT_OF_HOST_MEMORY ;
986987 goto out ;
987988 }
989+ * icd_phys_devs_array = new_ptr ;
988990 icd_phys_devs_array_size *= 2 ;
989991 }
990992 (* icd_phys_devs_array )[* icd_phys_devs_array_count ].device_count = 0 ;
0 commit comments