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();
}
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
// 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');
}