From ed149062d0e8407710f083aa85d28d27c4a45ecc Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Fri, 21 Jun 2024 08:38:42 +0000 Subject: [PATCH] 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 --- .../serviceability/jvmti/HeapMonitor/libHeapMonitorTest.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/libHeapMonitorTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/libHeapMonitorTest.cpp index 035aaef827e..b70f4834f23 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/libHeapMonitorTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/libHeapMonitorTest.cpp @@ -515,7 +515,9 @@ static void event_storage_augment_storage(EventStorage* storage) { ObjectTrace** new_objects = reinterpret_cast(malloc(new_max * sizeof(*new_objects))); 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); storage->live_objects = new_objects; storage->live_object_size = new_max;