X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/83efadb7f370ec190f9f2ad414059fcf0d26b931..d181c36eb6366cb7da719c95eef50b281cedbbdc:/src/common/string.cpp diff --git a/src/common/string.cpp b/src/common/string.cpp index 6ddd68f0c7..aa150ea4af 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -312,13 +312,15 @@ bool wxStringBase::AllocBeforeWrite(size_t nLen) pData->nAllocLength = nLen; m_pchData = pData->data(); } - - // now we have enough space, just update the string length - pData->nDataLength = nLen; } wxASSERT( !GetStringData()->IsShared() ); // we must be the only owner + // it doesn't really matter what the string length is as it's going to be + // overwritten later but, for extra safety, set it to 0 for now as we may + // have some junk in m_pchData + GetStringData()->nDataLength = 0; + return true; }