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