[ 1123124 ] wxStringBase::Alloc can change string length

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32124 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Ryan Norton 2005-02-18 03:53:56 +00:00
parent 518ba66331
commit 83efadb7f3

View 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;