Merge pull request #7507 from vrabaud:iplimage_overflow

pull/7531/head
Alexander Alekhin 8 years ago
commit 7793299e53
  1. 13
      modules/core/src/array.cpp

@ -834,6 +834,9 @@ cvCreateData( CvArr* arr )
if( !CvIPL.allocateData )
{
const int64 imageSize_tmp = (int64)img->widthStep*(int64)img->height;
if( (int64)img->imageSize != imageSize_tmp )
CV_Error( CV_StsNoMem, "Overflow for imageSize" );
img->imageData = img->imageDataOrigin =
(char*)cvAlloc( (size_t)img->imageSize );
}
@ -941,7 +944,10 @@ cvSetData( CvArr* arr, void* data, int step )
img->widthStep = min_step;
}
img->imageSize = img->widthStep * img->height;
const int64 imageSize_tmp = (int64)img->widthStep*(int64)img->height;
img->imageSize = (int)imageSize_tmp;
if( (int64)img->imageSize != imageSize_tmp )
CV_Error( CV_StsNoMem, "Overflow for imageSize" );
img->imageData = img->imageDataOrigin = (char*)data;
if( (((int)(size_t)data | step) & 7) == 0 &&
@ -2958,7 +2964,10 @@ cvInitImageHeader( IplImage * image, CvSize size, int depth,
image->widthStep = (((image->width * image->nChannels *
(image->depth & ~IPL_DEPTH_SIGN) + 7)/8)+ align - 1) & (~(align - 1));
image->origin = origin;
image->imageSize = image->widthStep * image->height;
const int64 imageSize_tmp = (int64)image->widthStep*(int64)image->height;
image->imageSize = (int)imageSize_tmp;
if( (int64)image->imageSize != imageSize_tmp )
CV_Error( CV_StsNoMem, "Overflow for imageSize" );
return image;
}

Loading…
Cancel
Save