Skip to content
Permalink
Browse files
fix potential overflow
  • Loading branch information
vcloarec authored and nyalldawson committed Jan 8, 2022
1 parent 789ca07 commit 08148555ab71115e4b63321a63ee455a9b6b448f
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/providers/wms/qgswmsprovider.cpp
@@ -1009,7 +1009,8 @@ bool QgsWmsProvider::readBlock( int bandNo, QgsRectangle const &viewExtent, int
}

QgsDebugMsgLevel( QStringLiteral( "image height = %1 bytesPerLine = %2" ).arg( image->height() ) . arg( image->bytesPerLine() ), 3 );
size_t myExpectedSize = pixelWidth * pixelHeight * 4;
size_t pixelsCount = pixelWidth * pixelHeight;
size_t myExpectedSize = pixelsCount * 4;
size_t myImageSize = image->height() * image->bytesPerLine();
if ( myExpectedSize != myImageSize ) // should not happen
{
@@ -1027,7 +1028,7 @@ bool QgsWmsProvider::readBlock( int bandNo, QgsRectangle const &viewExtent, int
data.resize( myImageSize );
const QRgb *inputPtr = reinterpret_cast<const QRgb *>( image->constBits() );
float *outputPtr = data.data();
for ( int i = 0; i < pixelWidth * pixelHeight; ++i )
for ( size_t i = 0; i < pixelsCount; ++i )
{
mConverter->convert( *inputPtr, outputPtr );
inputPtr++;

0 comments on commit 0814855

Please sign in to comment.