X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c08d805c5a3fb6495509fb2e25af4e398ca434cc..179e085f05fab385b89a18281e115003de890388:/src/common/string.cpp diff --git a/src/common/string.cpp b/src/common/string.cpp index d448b4b306..6ddd68f0c7 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -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;