Index: src/libstring/TString.cpp =================================================================== diff -u -r2e4eacb299f21d06196fe13140b4b0d095abdca9 -rc89285627fcbfd03036064ec6f834e4fa6841048 --- src/libstring/TString.cpp (.../TString.cpp) (revision 2e4eacb299f21d06196fe13140b4b0d095abdca9) +++ src/libstring/TString.cpp (.../TString.cpp) (revision c89285627fcbfd03036064ec6f834e4fa6841048) @@ -570,6 +570,8 @@ size_t stFindPos = 0; while ((stFindPos = Find(pszWhat, stStartPos)) != npos) { + stThisLen = GetLength(); + // Sample string "ABCdddb" (len:6), searching for "dd" (len 2) to replace with "x" (len 1) // found string pos is: [stFindPos, stFindPos + stWhatLen) -- sample ref: [3, 3 + 2) // we need to @@ -672,7 +674,7 @@ { size_t stNewLen = stLen;//ROUNDUP(stLen, CHUNK_INCSIZE); - wchar_t* pszNewBuffer = new wchar_t[stNewLen]; + wchar_t* pszNewBuffer = new wchar_t[stNewLen] { }; if (m_pszData && m_pszData[0] != L'\0') _tcsncpy_s(pszNewBuffer, stNewLen, m_pszData, GetLength() + 1); else