X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8ecf21b7db119d71e33e2651027570c4f91a690b..d94974609888885e0b75d0e01d901b03a6213979:/src/common/string.cpp diff --git a/src/common/string.cpp b/src/common/string.cpp index 2a3ce18e41..34776e1caa 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -267,6 +267,7 @@ wxString::wxString(const char *psz, wxMBConv& conv, size_t nLength) if ( conv.MB2WC(m_pchData, psz, nLen + 1) != (size_t)-1 ) { // initialized ok + m_pchData[nLen] = 0; return; } //else: the conversion failed -- leave the string empty (what else?) @@ -773,7 +774,7 @@ wxString wxString::FromAscii(const char ascii) wxString res; res += (wchar_t)(unsigned char) ascii; - + return res; } @@ -957,8 +958,13 @@ wxString wxString::AfterFirst(wxChar ch) const } // replace first (or all) occurences of some substring with another one -size_t wxString::Replace(const wxChar *szOld, const wxChar *szNew, bool bReplaceAll) +size_t +wxString::Replace(const wxChar *szOld, const wxChar *szNew, bool bReplaceAll) { + // if we tried to replace an empty string we'd enter an infinite loop below + wxCHECK_MSG( szOld && *szOld && szNew, 0, + _T("wxString::Replace(): invalid parameter") ); + size_t uiCount = 0; // count of replacements made size_t uiOldLen = wxStrlen(szOld);