diff --git a/libcxx/src/locale.cpp b/libcxx/src/locale.cpp --- a/libcxx/src/locale.cpp +++ b/libcxx/src/locale.cpp @@ -5128,7 +5128,7 @@ mb = mbstate_t(); const char* bb = buf; size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_); - if (j == size_t(-1)) + if (j == size_t(-1) || j == 0) __throw_runtime_error("locale not supported"); wbe = wbuf + j; __weeks_[i].assign(wbuf, wbe); @@ -5136,7 +5136,7 @@ mb = mbstate_t(); bb = buf; j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_); - if (j == size_t(-1)) + if (j == size_t(-1) || j == 0) __throw_runtime_error("locale not supported"); wbe = wbuf + j; __weeks_[i+7].assign(wbuf, wbe); @@ -5149,7 +5149,7 @@ mb = mbstate_t(); const char* bb = buf; size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_); - if (j == size_t(-1)) + if (j == size_t(-1) || j == 0) __throw_runtime_error("locale not supported"); wbe = wbuf + j; __months_[i].assign(wbuf, wbe); @@ -5157,7 +5157,7 @@ mb = mbstate_t(); bb = buf; j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_); - if (j == size_t(-1)) + if (j == size_t(-1) || j == 0) __throw_runtime_error("locale not supported"); wbe = wbuf + j; __months_[i+12].assign(wbuf, wbe);