Check for self-assignment in wxArrayString

Assigning array to itself destroyed its contents -- check for this now.

Closes #17619.
This commit is contained in:
Vadim Zeitlin
2016-08-09 01:07:59 +02:00
parent 3572c2c654
commit 985ff1e26e
2 changed files with 14 additions and 0 deletions

View File

@@ -89,7 +89,14 @@ wxArrayString::wxArrayString(const wxArrayString& src)
wxArrayString& wxArrayString::operator=(const wxArrayString& src)
{
if ( m_nSize > 0 )
{
// Do this test here to avoid unnecessary overhead when assigning to an
// empty array, in that case there is no harm in self-assignment.
if ( &src == this )
return *this;
Clear();
}
Copy(src);