From be1d374bc54d43aae3b3c1feace22d38fe2156b6 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Mon, 27 May 2024 14:32:30 +0000 Subject: [PATCH] 8332825: ubsan: guardedMemory.cpp:35:11: runtime error: null pointer passed as argument 2, which is declared to never be null Reviewed-by: clanger, mdoerr --- src/hotspot/share/memory/guardedMemory.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/memory/guardedMemory.cpp b/src/hotspot/share/memory/guardedMemory.cpp index 91adb016c6578..7b676d725882a 100644 --- a/src/hotspot/share/memory/guardedMemory.cpp +++ b/src/hotspot/share/memory/guardedMemory.cpp @@ -32,7 +32,9 @@ void* GuardedMemory::wrap_copy(const void* ptr, const size_t len, const void* ta if (outerp != nullptr) { GuardedMemory guarded(outerp, len, tag); void* innerp = guarded.get_user_ptr(); - memcpy(innerp, ptr, len); + if (ptr != nullptr) { + memcpy(innerp, ptr, len); + } return innerp; } return nullptr; // OOM