From f966a73d40f3799781b083fd66413a8d95a75a6e Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sat, 16 Jun 2007 14:29:52 +0000 Subject: [PATCH] fixed FromUTF8() to accept NULL as well as len==npos; this fixes crashes when loading XML files in UTF-8 build with wxUSE_STL=1 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46491 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/string.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/wx/string.h b/include/wx/string.h index d40abcea3c..3296fb40f0 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -1207,11 +1207,19 @@ public: #if wxUSE_UNICODE_UTF8 static wxString FromUTF8(const char *utf8) { + if ( !utf8 ) + return wxEmptyString; + wxASSERT( wxStringOperations::IsValidUtf8String(utf8) ); return FromImpl(wxStringImpl(utf8)); } static wxString FromUTF8(const char *utf8, size_t len) { + if ( !utf8 ) + return wxEmptyString; + if ( len == npos ) + return FromUTF8(utf8); + wxASSERT( wxStringOperations::IsValidUtf8String(utf8, len) ); return FromImpl(wxStringImpl(utf8, len)); } -- 2.50.0