// Author: Vadim Zeitlin, Ryan Norton
// Modified by:
// Created: 29/01/98
-// RCS-ID: $Id$
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// (c) 2004 Ryan Norton <wxprojects@comcast.net>
// Licence: wxWindows licence
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');
}