diff --git a/modules/core/include/opencv2/core/mat.inl.hpp b/modules/core/include/opencv2/core/mat.inl.hpp index bfa28a1cdf..4d8d6f059d 100644 --- a/modules/core/include/opencv2/core/mat.inl.hpp +++ b/modules/core/include/opencv2/core/mat.inl.hpp @@ -1744,6 +1744,11 @@ Mat_<_Tp>::Mat_(const std::array<_Tp, _Nm>& arr, bool copyData) template inline Mat_<_Tp>& Mat_<_Tp>::operator = (const Mat& m) { + if (m.empty()) + { + release(); + return *this; + } if( traits::Type<_Tp>::value == m.type() ) { Mat::operator = (m); @@ -2125,6 +2130,11 @@ Mat_<_Tp>::Mat_(Mat&& m) template inline Mat_<_Tp>& Mat_<_Tp>::operator = (Mat&& m) { + if (m.empty()) + { + release(); + return *this; + } if( traits::Type<_Tp>::value == m.type() ) { Mat::operator = ((Mat&&)m);