Skip to content

Commit ccdf452

Browse files
committed
[raster] Fix unintentional int overflow
1 parent 4a4a700 commit ccdf452

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/core/raster/qgsrasterblock.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ bool QgsRasterBlock::convert( QGis::DataType destDataType )
679679

680680
if ( typeIsNumeric( mDataType ) && typeIsNumeric( destDataType ) )
681681
{
682-
void *data = convert( mData, mDataType, destDataType, mWidth * mHeight );
682+
void *data = convert( mData, mDataType, destDataType, ( qgssize )mWidth * ( qgssize )mHeight );
683683

684684
if ( data == 0 )
685685
{
@@ -728,7 +728,7 @@ void QgsRasterBlock::applyNoDataValues( const QgsRasterRangeList & rangeList )
728728
return;
729729
}
730730

731-
qgssize size = mWidth * mHeight;
731+
qgssize size = ( qgssize )mWidth * ( qgssize )mHeight;
732732
for ( qgssize i = 0; i < size; ++i )
733733
{
734734
double val = value( i );

src/core/raster/qgsrasterdataprovider.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ QgsRasterBlock * QgsRasterDataProvider::block( int theBandNo, QgsRectangle cons
182182
return block;
183183
}
184184

185-
qgssize tmpIndex = tmpRow * tmpWidth + tmpCol;
186-
qgssize index = row * theWidth + col;
185+
qgssize tmpIndex = ( qgssize )tmpRow * ( qgssize )tmpWidth + tmpCol;
186+
qgssize index = row * ( qgssize )theWidth + col;
187187

188188
char *tmpBits = tmpBlock->bits( tmpIndex );
189189
char *bits = block->bits( index );

0 commit comments

Comments
 (0)