From 93f8e7ba747af55324a0752afc7f5e3fcc650732 Mon Sep 17 00:00:00 2001 From: mdim Date: Tue, 22 Jan 2013 00:37:27 +0400 Subject: [PATCH] check of keypoint index range in drawMatches --- modules/features2d/src/draw.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/features2d/src/draw.cpp b/modules/features2d/src/draw.cpp index 4c932711d..144f71a26 100644 --- a/modules/features2d/src/draw.cpp +++ b/modules/features2d/src/draw.cpp @@ -200,10 +200,13 @@ void drawMatches( const Mat& img1, const vector& keypoints1, // draw matches for( size_t m = 0; m < matches1to2.size(); m++ ) { - int i1 = matches1to2[m].queryIdx; - int i2 = matches1to2[m].trainIdx; if( matchesMask.empty() || matchesMask[m] ) { + int i1 = matches1to2[m].queryIdx; + int i2 = matches1to2[m].trainIdx; + CV_Assert(i1 >= 0 && i1 < static_cast(keypoints1.size())); + CV_Assert(i2 >= 0 && i2 < static_cast(keypoints2.size())); + const KeyPoint &kp1 = keypoints1[i1], &kp2 = keypoints2[i2]; _drawMatch( outImg, outImg1, outImg2, kp1, kp2, matchColor, flags ); }