From: Vadim Zeitlin Date: Sun, 15 Jun 2003 19:33:04 +0000 (+0000) Subject: check parmateres in Replace() (bug 752716) X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a8f1f1b23b32cb72c5aef4df2ec52049e7d82fcd?ds=inline check parmateres in Replace() (bug 752716) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21170 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/string.cpp b/src/common/string.cpp index 9f97667da3..34776e1caa 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -958,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);