X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9a83f860948059b0273b5cc6d9e43fadad3ebfca..a3b7db872925df2921f36637a84085ec04cf977a:/src/common/stringimpl.cpp diff --git a/src/common/stringimpl.cpp b/src/common/stringimpl.cpp index 429f3843bd..498793722e 100644 --- a/src/common/stringimpl.cpp +++ b/src/common/stringimpl.cpp @@ -395,14 +395,14 @@ bool wxStringImpl::Alloc(size_t nLen) wxStringImpl::iterator wxStringImpl::begin() { - if (length() > 0) + if ( !empty() ) CopyBeforeWrite(); return m_pchData; } wxStringImpl::iterator wxStringImpl::end() { - if (length() > 0) + if ( !empty() ) CopyBeforeWrite(); return m_pchData + length(); } @@ -528,7 +528,7 @@ size_t wxStringImpl::rfind(const wxStringImpl& str, size_t nStart) const if ( length() >= str.length() ) { // avoids a corner case later - if ( length() == 0 && str.length() == 0 ) + if ( empty() && str.empty() ) return 0; // "top" is the point where search starts from @@ -681,7 +681,11 @@ bool wxStringImpl::AssignCopy(size_t nSrcLen, // allocation failure handled by caller return false; } - memcpy(m_pchData, pszSrcData, nSrcLen*sizeof(wxStringCharType)); + + // use memmove() and not memcpy() here as we might be copying from our own + // buffer in case of assignment such as "s = s.c_str()" (see #11294) + memmove(m_pchData, pszSrcData, nSrcLen*sizeof(wxStringCharType)); + GetStringData()->nDataLength = nSrcLen; m_pchData[nSrcLen] = wxT('\0'); }