1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

imgcodesc: fix code problems with integer overflow / address arithmetic / UB

This commit is contained in:
Alexander Alekhin
2017-08-23 15:15:27 +03:00
parent b67c64e2c8
commit aacae20657
8 changed files with 50 additions and 37 deletions
+3 -3
View File
@@ -156,7 +156,7 @@ bool Jpeg2KDecoder::readData( Mat& img )
bool result = false;
int color = img.channels() > 1;
uchar* data = img.ptr();
int step = (int)img.step;
size_t step = img.step;
jas_stream_t* stream = (jas_stream_t*)m_stream;
jas_image_t* image = (jas_image_t*)m_image;
@@ -252,9 +252,9 @@ bool Jpeg2KDecoder::readData( Mat& img )
if( !jas_image_readcmpt( image, cmptlut[i], 0, 0, xend / xstep, yend / ystep, buffer ))
{
if( img.depth() == CV_8U )
result = readComponent8u( data + i, buffer, step, cmptlut[i], maxval, offset, ncmpts );
result = readComponent8u( data + i, buffer, validateToInt(step), cmptlut[i], maxval, offset, ncmpts );
else
result = readComponent16u( ((unsigned short *)data) + i, buffer, step / 2, cmptlut[i], maxval, offset, ncmpts );
result = readComponent16u( ((unsigned short *)data) + i, buffer, validateToInt(step / 2), cmptlut[i], maxval, offset, ncmpts );
if( !result )
{
i = ncmpts;