From 595ec6b852588df9008a5e73755da224f5b14b99 Mon Sep 17 00:00:00 2001 From: Guo Yejun Date: Thu, 8 Jan 2015 16:10:38 +0800 Subject: [PATCH] correct the size of buf which holds integral sum/sumsq layer_dy is not initialized correctly, it results in a small height of the buffer, and so memory write is out of range in cv::integral. --- modules/objdetect/src/cascadedetect.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/objdetect/src/cascadedetect.cpp b/modules/objdetect/src/cascadedetect.cpp index 6ddc0c878f..c11e552666 100644 --- a/modules/objdetect/src/cascadedetect.cpp +++ b/modules/objdetect/src/cascadedetect.cpp @@ -449,6 +449,12 @@ bool FeatureEvaluator::updateScaleData( Size imgsz, const std::vector& _s s.ystep = sc >= 2 ? 1 : 2; s.scale = sc; s.szi = Size(sz.width+1, sz.height+1); + + if( i == 0 ) + { + layer_dy = s.szi.height; + } + if( layer_ofs.x + s.szi.width > sbufSize.width ) { layer_ofs = Point(0, layer_ofs.y + layer_dy);