From 4692d4b36e5aed35a8d52f4ffc66b06c2a456e6d Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Thu, 4 Jul 2013 17:06:00 +0400 Subject: [PATCH] Fix bug: cv::String would break if assigned to itself. --- modules/core/include/opencv2/core/cvstd.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/core/include/opencv2/core/cvstd.hpp b/modules/core/include/opencv2/core/cvstd.hpp index 0232c6d..0f96941 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_; -- 2.7.4