From 2e82111ee05b1600d861b6f8379caeccb332ea83 Mon Sep 17 00:00:00 2001 From: ser1zw Date: Mon, 20 Aug 2012 16:16:45 +0900 Subject: [PATCH] fix CvMat#match_descriptors for invalid image array --- ext/opencv/cvmat.cpp | 2 +- test/test_cvmat_matching.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) mode change 100644 => 100755 test/test_cvmat_matching.rb diff --git a/ext/opencv/cvmat.cpp b/ext/opencv/cvmat.cpp index 24e69d7..8f03091 100644 --- a/ext/opencv/cvmat.cpp +++ b/ext/opencv/cvmat.cpp @@ -5368,7 +5368,7 @@ rb_match_descriptors(int argc, VALUE *argv, VALUE self) cv::Mat queryImage = CVMAT(self); std::vector trainImages; for(int i=0; i < RARRAY_LEN(images); i++) { - trainImages.push_back(CVMAT(RARRAY_PTR(images)[i])); + trainImages.push_back(CVMAT_WITH_CHECK(RARRAY_PTR(images)[i])); } cv::Ptr featureDetector = cv::FeatureDetector::create(RSTRING_PTR(detector_type)); diff --git a/test/test_cvmat_matching.rb b/test/test_cvmat_matching.rb old mode 100644 new mode 100755 index aea8907..74583e3 --- a/test/test_cvmat_matching.rb +++ b/test/test_cvmat_matching.rb @@ -48,4 +48,10 @@ class TestCvMat_matching < OpenCVTestCase @query.match_descriptors(@images, "SURF", "SURF", "wrong") end end + + def test_match_descriptors_with_invalid_image_array + assert_raise TypeError do + @query.match_descriptors([DUMMY_OBJ, DUMMY_OBJ]) + end + end end