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
This commit is contained in:
parent
591e32d624
commit
1ca23672a0
@ -3920,7 +3920,8 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
|
||||
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 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
|
||||
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)
|
||||
|
@ -33,5 +33,7 @@ int main()
|
||||
assert(ws == L"\x40003");
|
||||
ws = myconv.from_bytes(bs.data(), bs.data() + bs.size());
|
||||
assert(ws == L"\x40003");
|
||||
ws = myconv.from_bytes("");
|
||||
assert(ws.size() == 0);
|
||||
}
|
||||
}
|
||||
|
@ -33,5 +33,7 @@ int main()
|
||||
assert(bs == "\xF1\x80\x80\x83");
|
||||
bs = myconv.to_bytes(ws.data(), ws.data() + ws.size());
|
||||
assert(bs == "\xF1\x80\x80\x83");
|
||||
bs = myconv.to_bytes(L"");
|
||||
assert(bs.size() == 0);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user