core: forbid handling of the case when src=dst in cv::repeat
authorVladislav Sovrasov <sovrasov.vlad@gmail.com>
Mon, 26 Jun 2017 09:30:03 +0000 (12:30 +0300)
committerVladislav Sovrasov <sovrasov.vlad@gmail.com>
Mon, 26 Jun 2017 11:02:52 +0000 (14:02 +0300)
modules/core/src/copy.cpp
modules/core/test/test_misc.cpp

index ec039d4..87c0b9d 100644 (file)
@@ -856,6 +856,7 @@ void repeat(InputArray _src, int ny, int nx, OutputArray _dst)
 {
     CV_INSTRUMENT_REGION()
 
+    CV_Assert(_src.getObj() != _dst.getObj());
     CV_Assert( _src.dims() <= 2 );
     CV_Assert( ny > 0 && nx > 0 );
 
index e018d74..edbd184 100644 (file)
@@ -145,3 +145,12 @@ TEST(Core_String, end_method_regression)
     cv::String new_string(old_string.begin(), old_string.end());
     EXPECT_EQ(6u, new_string.size());
 }
+
+TEST(Core_Copy, repeat_regression_8972)
+{
+    Mat src = (Mat_<int>(1, 4) << 1, 2, 3, 4);
+
+    ASSERT_ANY_THROW({
+                         repeat(src, 5, 1, src);
+                     });
+}