Article ID: 142385
Article Last Modified on 11/21/2006
str1 += _T("");
Check for empty CStrings prior to appending:
if (!str2.IsEmpty())
str1 += str2;
/* Compile options needed: default
*/
{
CString str1, str2;
str1 = _T("allocspace"); // length of RHS > 0, allocate memory
// str1 += str2 will otherwise do a fast copy
// if both CStrings are uninitialized
str1 = _T(""); // make str1 NULL
// operator= will put '\0' at m_pchData[0]
str2 = str1; // str1 and str2 share the same m_pchData.
// m_pchData now has ref count of 2
str1 += _T(""); // m_pchData has ref count of 1 but both str1
// and str2 use this data.
}
Additional query words: kbVC400bug 4.00 4.10
Keywords: kbbug kbfix kbnoupdate kbvc410fix KB142385