]> git.saurik.com Git - wxWidgets.git/commitdiff
[ 1123124 ] wxStringBase::Alloc can change string length
authorRyan Norton <wxprojects@comcast.net>
Fri, 18 Feb 2005 03:53:56 +0000 (03:53 +0000)
committerRyan Norton <wxprojects@comcast.net>
Fri, 18 Feb 2005 03:53:56 +0000 (03:53 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32124 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/string.cpp

index d448b4b306203ad4468b3614f4eca01739524eae..6ddd68f0c7cfb69441da9a37452ca44fb5268189 100644 (file)
@@ -380,7 +380,9 @@ bool wxStringBase::Alloc(size_t nLen)
         // allocation failure handled by caller
         return false;
       }
-      memcpy(m_pchData, pData->data(), nOldLen*sizeof(wxChar));
+      // +1 to copy the terminator, too
+      memcpy(m_pchData, pData->data(), (nOldLen+1)*sizeof(wxChar));
+      GetStringData()->nDataLength = nOldLen;
     }
     else {
       nLen += EXTRA_ALLOC;