From 2bef5b4a877f4d3bc766558b8782b7b57dee79a8 Mon Sep 17 00:00:00 2001 From: Dhamoder Nalla Date: Tue, 28 Jan 2025 11:32:00 +0000 Subject: [PATCH] 8348323: Corrupted timezone string in JVM crash log Reviewed-by: dholmes, amitkumar, kevinw --- src/hotspot/share/runtime/os.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/hotspot/share/runtime/os.cpp b/src/hotspot/share/runtime/os.cpp index 094d68e1a84..0654bd3e092 100644 --- a/src/hotspot/share/runtime/os.cpp +++ b/src/hotspot/share/runtime/os.cpp @@ -1212,8 +1212,7 @@ void os::print_date_and_time(outputStream *st, char* buf, size_t buflen) { if (localtime_pd(&tloc, &tz) != nullptr) { wchar_t w_buf[80]; size_t n = ::wcsftime(w_buf, 80, L"%Z", &tz); - if (n > 0) { - ::wcstombs(buf, w_buf, buflen); + if (n > 0 && ::wcstombs(buf, w_buf, buflen) != (size_t)-1) { st->print("Time: %s %s", timestring, buf); } else { st->print("Time: %s", timestring);