fixed crash in cvDrawContours when abs(maxLevel) is too big

This commit is contained in:
Vadim Pisarevsky 2010-12-04 15:31:42 +00:00
parent 11ed55ddb4
commit 9948ed88b0

View File

@ -2033,12 +2033,14 @@ cvDrawContours( void* _img, CvSeq* contour,
scalarToRawData( externalColor, ext_buf, img.type(), 0 ); scalarToRawData( externalColor, ext_buf, img.type(), 0 );
scalarToRawData( holeColor, hole_buf, img.type(), 0 ); scalarToRawData( holeColor, hole_buf, img.type(), 0 );
maxLevel = MAX(maxLevel, INT_MIN-2);
maxLevel = MIN(maxLevel, INT_MAX-1);
if( maxLevel < 0 ) if( maxLevel < 0 )
{ {
h_next = contour->h_next; h_next = contour->h_next;
contour->h_next = 0; contour->h_next = 0;
maxLevel = -maxLevel+1; maxLevel = -maxLevel+1;
maxLevel -= maxLevel < 0;
} }
cvInitTreeNodeIterator( &iterator, contour, maxLevel ); cvInitTreeNodeIterator( &iterator, contour, maxLevel );