From: Vadim Zeitlin Date: Fri, 10 Oct 2008 16:11:40 +0000 (+0000) Subject: don't crash when streaming out a wxString into an std::ostream, just set the failbit... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/ddf01bdb960d3575c6f10ada189290bb6e09758d don't crash when streaming out a wxString into an std::ostream, just set the failbit instead git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56214 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/string.cpp b/src/common/string.cpp index 5729c48c65..04a606a3c5 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -168,7 +168,13 @@ static wxStrCacheStatsDumper s_showCacheStats; wxSTD ostream& operator<<(wxSTD ostream& os, const wxCStrData& str) { #if wxUSE_UNICODE && !wxUSE_UNICODE_UTF8 - return os << (const char *)str.AsCharBuf(); + const wxCharBuffer buf(str.AsCharBuf()); + if ( !buf ) + os.clear(wxSTD ios_base::failbit); + else + os << buf.data(); + + return os; #else return os << str.AsInternal(); #endif