vector subscript out of range when call buildPyramid() (Bug #2975)


Added by qually jiang almost 12 years ago. Updated over 11 years ago.


Status:Done Start date:2013-04-17
Priority:Normal Due date:
Assignee:Ivan Korolev % Done:

0%

Category:core
Target version:2.4.6 Estimated time:1.00 hour
Affected version:2.4.5 (latest release) Operating System:
Difficulty: HW Platform:
Pull request:

Description

void foo(cv::Mat1f sigma) {
cv::vector<cv::Mat1f> gs;
cv::buildPyramid(sigma, gs, 5);
}

will cause vector subscript out of range exception.

in matrix.cpp, this function
void _OutputArray::create(int dims, const int* sizes, int mtype, int i, bool allowTransposed, int fixedDepthMask) const,
...
CV_Assert( k STD_VECTOR_MAT );
//if( k STD_VECTOR_MAT ) {
vector<Mat>& v = (vector<Mat>)obj;

if( i < 0 )
{
CV_Assert( dims 2 && (sizes[0] 1 || sizes[1] 1 || sizes[0]*sizes[1] 0) );
size_t len = sizes[0]*sizes[1] > 0 ? sizes[0] + sizes[1] - 1 : 0, len0 = v.size();
CV_Assert(!fixedSize() || len == len0);
v.resize(len);
if( fixedType() ) {
int _type = CV_MAT_TYPE(flags);
for( size_t j = len0; j < len; j++ ) {
if( v[i].type() == _type )
continue;
CV_Assert( v[i].empty() );
v[i].flags = (v[i].flags & ~CV_MAT_TYPE_MASK) | _type;
}
}
return;
}
Inside the loop, loop iterator is j but v[i] was used. And i must be less than 0. And that caused the exception. Should change all v[i] to v[j] in this block.

Associated revisions

Revision ccbc764c
Added by Roman Donchenko over 10 years ago

Merge pull request #2975 from asmorkalov:ocv_cuda_6.5_fix

History

Updated by Ivan Korolev over 11 years ago

  • Assignee changed from Vadim Pisarevsky to Ivan Korolev

Updated by Ivan Korolev over 11 years ago

The bug related to wrong indices was fixed by Andrey Kamaev (ea5225ef, 2013-03-31), so the buildPyramid() bug wasn't reproduced.

  • Status changed from Open to Done

Also available in: Atom PDF