From 83efadb7f370ec190f9f2ad414059fcf0d26b931 Mon Sep 17 00:00:00 2001 From: Ryan Norton Date: Fri, 18 Feb 2005 03:53:56 +0000 Subject: [PATCH] [ 1123124 ] wxStringBase::Alloc can change string length git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32124 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/string.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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;