fix bug when appending string to itself (closes bug 1942116) [backport of r48302 from trunk]
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@53167 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -844,6 +844,16 @@ bool wxStringBase::ConcatSelf(size_t nSrcLen, const wxChar *pszSrcData,
|
|||||||
size_t nLen = pData->nDataLength;
|
size_t nLen = pData->nDataLength;
|
||||||
size_t nNewLen = nLen + nSrcLen;
|
size_t nNewLen = nLen + nSrcLen;
|
||||||
|
|
||||||
|
// take special care when appending part of this string to itself: the code
|
||||||
|
// below reallocates our buffer and this invalidates pszSrcData pointer so
|
||||||
|
// we have to copy it in another temporary string in this case (but avoid
|
||||||
|
// doing this unnecessarily)
|
||||||
|
if ( pszSrcData >= m_pchData && pszSrcData < m_pchData + nLen )
|
||||||
|
{
|
||||||
|
wxStringBase tmp(pszSrcData, nSrcLen);
|
||||||
|
return ConcatSelf(nSrcLen, tmp.m_pchData, nSrcLen);
|
||||||
|
}
|
||||||
|
|
||||||
// alloc new buffer if current is too small
|
// alloc new buffer if current is too small
|
||||||
if ( pData->IsShared() ) {
|
if ( pData->IsShared() ) {
|
||||||
STATISTICS_ADD(ConcatHit, 0);
|
STATISTICS_ADD(ConcatHit, 0);
|
||||||
|
Reference in New Issue
Block a user