[libcxx-commits] [PATCH] D69553: [libcxx] Error out if __libcpp_mbsrtowcs_l fails to convert anything in __time_get_storage

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Nov 3 07:15:46 PST 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG1127ef789c02: [libcxx] Error out if __libcpp_mbsrtowcs_l fails in __time_get_storage (authored by mstorsjo).
Herald added a project: libc++.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69553/new/

https://reviews.llvm.org/D69553

Files:
  libcxx/src/locale.cpp


Index: libcxx/src/locale.cpp
===================================================================
--- libcxx/src/locale.cpp
+++ 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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69553.302578.patch
Type: text/x-patch
Size: 1542 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20201103/526e9f03/attachment-0001.bin>


More information about the libcxx-commits mailing list