mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 22:44:02 +08:00
Fix imageSize overflow in IplImage
This commit is contained in:
parent
157a90ac46
commit
a89aa8c90a
@ -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…
Reference in New Issue
Block a user