8333361: ubsan,test : libHeapMonitorTest.cpp:518:9: runtime error: null pointer passed as argument 2, which is declared to never be null

Reviewed-by: asteiner, lucy, amenkov
This commit is contained in:
Matthias Baesken 2024-06-21 08:38:42 +00:00
parent bdd96604ae
commit ed149062d0

View file

@ -515,7 +515,9 @@ static void event_storage_augment_storage(EventStorage* storage) {
ObjectTrace** new_objects = reinterpret_cast<ObjectTrace**>(malloc(new_max * sizeof(*new_objects))); ObjectTrace** new_objects = reinterpret_cast<ObjectTrace**>(malloc(new_max * sizeof(*new_objects)));
int current_count = storage->live_object_count; int current_count = storage->live_object_count;
memcpy(new_objects, storage->live_objects, current_count * sizeof(*new_objects)); if (storage->live_objects != nullptr) {
memcpy(new_objects, storage->live_objects, current_count * sizeof(*new_objects));
}
free(storage->live_objects); free(storage->live_objects);
storage->live_objects = new_objects; storage->live_objects = new_objects;
storage->live_object_size = new_max; storage->live_object_size = new_max;