Fix bug: cv::String would break if assigned to itself.
This commit is contained in:
parent
70deda354a
commit
4692d4b36e
@ -580,6 +580,8 @@ String::~String()
|
|||||||
inline
|
inline
|
||||||
String& String::operator=(const String& str)
|
String& String::operator=(const String& str)
|
||||||
{
|
{
|
||||||
|
if (&str == this) return *this;
|
||||||
|
|
||||||
deallocate();
|
deallocate();
|
||||||
if (str.cstr_) CV_XADD(((int*)str.cstr_)-1, 1);
|
if (str.cstr_) CV_XADD(((int*)str.cstr_)-1, 1);
|
||||||
cstr_ = str.cstr_;
|
cstr_ = str.cstr_;
|
||||||
|
Loading…
Reference in New Issue
Block a user