Index: src/libstring/TString.cpp
===================================================================
diff -u -r2e4eacb299f21d06196fe13140b4b0d095abdca9 -rdf130d0560105f3f098e84d3adb4810837598456
--- src/libstring/TString.cpp	(.../TString.cpp)	(revision 2e4eacb299f21d06196fe13140b4b0d095abdca9)
+++ src/libstring/TString.cpp	(.../TString.cpp)	(revision df130d0560105f3f098e84d3adb4810837598456)
@@ -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
Index: src/libstring/Tests/TestsTString.cpp
===================================================================
diff -u -r07f5ed57f11f0b908313f692fc4830401f0db552 -rdf130d0560105f3f098e84d3adb4810837598456
--- src/libstring/Tests/TestsTString.cpp	(.../TestsTString.cpp)	(revision 07f5ed57f11f0b908313f692fc4830401f0db552)
+++ src/libstring/Tests/TestsTString.cpp	(.../TestsTString.cpp)	(revision df130d0560105f3f098e84d3adb4810837598456)
@@ -549,6 +549,15 @@
 	EXPECT_EQ(strValue, _T("Some song"));
 }
 
+TEST(TStringTests, Replace_MultipleTimes)
+{
+	TString strValue(_T("Soome stering"));
+	strValue.Replace(_T("o"), _T("xyz"));
+	strValue.Replace(_T("e"), _T("abc"));
+
+	EXPECT_EQ(strValue, _T("Sxyzxyzmabc stabcring"));
+}
+
 TEST(TStringTests, Replace_EmptyStringWithPtrToString)
 {
 	TString strValue;