Fixed a bug in wstring_convert concerning zero-length inputs. Thanks to Jonathan Coxhead for reporting this bug.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@160136 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/locale b/include/locale
index bec27f6..ee0a6a0 100644
--- a/include/locale
+++ b/include/locale
@@ -3920,7 +3920,8 @@
if (__cvtptr_ != nullptr)
{
wide_string __ws(2*(__frm_end - __frm), _Elem());
- __ws.resize(__ws.capacity());
+ if (__frm != __frm_end)
+ __ws.resize(__ws.capacity());
codecvt_base::result __r = codecvt_base::ok;
state_type __st = __cvtstate_;
if (__frm != __frm_end)
@@ -3980,7 +3981,8 @@
if (__cvtptr_ != nullptr)
{
byte_string __bs(2*(__frm_end - __frm), char());
- __bs.resize(__bs.capacity());
+ if (__frm != __frm_end)
+ __bs.resize(__bs.capacity());
codecvt_base::result __r = codecvt_base::ok;
state_type __st = __cvtstate_;
if (__frm != __frm_end)