Fix caching wrong length in wxString(str, len) ctor in UTF-8 build.

A length greater than that of the source string could be passed to this ctor.
This worked correctly, i.e. created a string which was a copy of the source
one but cached a wrong length for it.

Avoid this by explicitly checking the length before caching it in
wxString::assign(str, len).

See #14130.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70986 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-03-23 15:13:08 +00:00
parent d1485d8177
commit bd42a07c7a
2 changed files with 14 additions and 0 deletions

View File

@@ -190,6 +190,8 @@ void StringTestCase::Constructors()
CPPUNIT_ASSERT_EQUAL( L"Hello", wxString(L"Hello", 5) );
#endif // wxUSE_UNICODE
CPPUNIT_ASSERT_EQUAL( 0, wxString(wxString(), 17).length() );
static const char *s = "?really!";
const char *start = wxStrchr(s, 'r');
const char *end = wxStrchr(s, '!');