diff --git a/modules/core/include/opencv2/core/cvstd.hpp b/modules/core/include/opencv2/core/cvstd.hpp index 0232c6d084..0f96941df1 100644 --- a/modules/core/include/opencv2/core/cvstd.hpp +++ b/modules/core/include/opencv2/core/cvstd.hpp @@ -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_;