8348323: Corrupted timezone string in JVM crash log

Reviewed-by: dholmes, amitkumar, kevinw
This commit is contained in:
Dhamoder Nalla 2025-01-28 11:32:00 +00:00 committed by Kevin Walls
parent 3a8680e919
commit 2bef5b4a87

View File

@ -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);