diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index 5816c1f80f..8e36a44dbf 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -684,6 +684,8 @@ template inline void Mat::push_back(const _Tp& elem) { if( !data ) { + CV_Assert((type()==0) || (DataType<_Tp>::type == type())); + *this = Mat(1, 1, DataType<_Tp>::type, (void*)&elem).clone(); return; }