diff --git a/src/common/string.cpp b/src/common/string.cpp index 2d608d1eb8..bd9857e5cc 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -1551,8 +1551,8 @@ size_t wxString::Replace(const wxChar *szOld, //replace this occurance of the old string with the new one replace(dwPos, uiOldLen, szNew, uiNewLen); - //move up pos past the old string - dwPos += uiOldLen; + //move up pos past the string that was replaced + dwPos += uiNewLen; //increase replace count ++uiCount; diff --git a/tests/strings/strings.cpp b/tests/strings/strings.cpp index 3ff5fde7ec..652dc86eb7 100644 --- a/tests/strings/strings.cpp +++ b/tests/strings/strings.cpp @@ -476,8 +476,8 @@ void StringTestCase::Replace() CPPUNIT_ASSERT( s == wxString(r,rlen) ); \ } - TEST_WXREPLACE( _T("null\0char"), 9, _T("c"), _T("d"), true, - _T("null\0dhar"), 9 ); + TEST_WXREPLACE( _T("null\0char"), 9, _T("c"), _T("de"), true, + _T("null\0dehar"), 10 ); #undef TEST_WXREPLACE #undef TEST_NULLCHARREPLACE