Skip to content

Commit 0bf7cbd

Browse files
committed
UBA does not accept NULL in memcpy source even with size==0
1 parent 5b7f61a commit 0bf7cbd

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/provider/provider_level_zero.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,9 +1071,12 @@ umf_result_t umfLevelZeroMemoryProviderResidentDeviceChange(
10711071
}
10721072
LOG_DEBUG("enlarging resident devices array from %u to %u",
10731073
ze_provider->resident_device_capacity, new_capacity);
1074-
memcpy(new_handles, ze_provider->resident_device_handles,
1075-
sizeof(ze_device_handle_t) *
1076-
ze_provider->resident_device_count);
1074+
if (ze_provider->resident_device_count > 0) {
1075+
ASSERT(ze_provider->resident_device_handles != NULL);
1076+
memcpy(new_handles, ze_provider->resident_device_handles,
1077+
sizeof(ze_device_handle_t) *
1078+
ze_provider->resident_device_count);
1079+
}
10771080
umf_ba_global_free(ze_provider->resident_device_handles);
10781081
ze_provider->resident_device_handles = new_handles;
10791082
ze_provider->resident_device_capacity = new_capacity;

0 commit comments

Comments
 (0)