Fix bug: cv::String would break if assigned to itself.
authorRoman Donchenko <roman.donchenko@itseez.com>
Thu, 4 Jul 2013 13:06:00 +0000 (17:06 +0400)
committerRoman Donchenko <roman.donchenko@itseez.com>
Thu, 4 Jul 2013 13:06:00 +0000 (17:06 +0400)
modules/core/include/opencv2/core/cvstd.hpp

index 0232c6d..0f96941 100644 (file)
@@ -580,6 +580,8 @@ String::~String()
 inline
 String& String::operator=(const String& str)
 {
+    if (&str == this) return *this;
+
     deallocate();
     if (str.cstr_) CV_XADD(((int*)str.cstr_)-1, 1);
     cstr_ = str.cstr_;