Fixed delete vs. delete[] in SimpleString - possible source of subtle errors
parent
e57b569531
commit
32871bfceb
|
@ -41,7 +41,7 @@ SimpleString::SimpleString (const SimpleString& other)
|
||||||
|
|
||||||
SimpleString SimpleString::operator= (const SimpleString& other)
|
SimpleString SimpleString::operator= (const SimpleString& other)
|
||||||
{
|
{
|
||||||
delete buffer_;
|
delete [] buffer_;
|
||||||
buffer_ = new char [other.size() + 1];
|
buffer_ = new char [other.size() + 1];
|
||||||
strcpy(buffer_, other.buffer_);
|
strcpy(buffer_, other.buffer_);
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -50,7 +50,7 @@ SimpleString SimpleString::operator= (const SimpleString& other)
|
||||||
SimpleString SimpleString::operator+ (const SimpleString& other)
|
SimpleString SimpleString::operator+ (const SimpleString& other)
|
||||||
{
|
{
|
||||||
SimpleString ret;
|
SimpleString ret;
|
||||||
delete ret.buffer_;
|
delete [] ret.buffer_;
|
||||||
ret.buffer_ = new char [size() + other.size() - 1];
|
ret.buffer_ = new char [size() + other.size() - 1];
|
||||||
strcpy(ret.buffer_, buffer_);
|
strcpy(ret.buffer_, buffer_);
|
||||||
strcat(ret.buffer_, other.buffer_);
|
strcat(ret.buffer_, other.buffer_);
|
||||||
|
|
Loading…
Reference in New Issue