calling insert("") would provoke an assert - now it's just ignored

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@622 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1998-08-22 20:44:07 +00:00
parent 1880e45211
commit cb6780ff01

View File

@@ -930,13 +930,15 @@ wxString& wxString::insert(size_t nPos, const wxString& str)
wxASSERT( str.GetStringData()->IsValid() ); wxASSERT( str.GetStringData()->IsValid() );
wxASSERT( nPos <= Len() ); wxASSERT( nPos <= Len() );
wxString strTmp; if ( !str.IsEmpty() ) {
char *pc = strTmp.GetWriteBuf(Len() + str.Len()); wxString strTmp;
strncpy(pc, c_str(), nPos); char *pc = strTmp.GetWriteBuf(Len() + str.Len());
strcpy(pc + nPos, str); strncpy(pc, c_str(), nPos);
strcpy(pc + nPos + str.Len(), c_str() + nPos); strcpy(pc + nPos, str);
strTmp.UngetWriteBuf(); strcpy(pc + nPos + str.Len(), c_str() + nPos);
*this = strTmp; strTmp.UngetWriteBuf();
*this = strTmp;
}
return *this; return *this;
} }