Skip to content

Commit

Permalink
Fix crashes when reading certain resampled raster files
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored and nyalldawson committed Jan 29, 2020
1 parent 8425ada commit 388277e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core/providers/gdal/qgsgdalprovider.cpp
Expand Up @@ -920,6 +920,7 @@ bool QgsGdalProvider::readBlock( int bandNo, QgsRectangle const &extent, int pi
for ( int row = 0; row < height; row++ )
{
int tmpRow = static_cast<int>( std::floor( -1. * ( tmpYMax - y ) / tmpYRes ) );
tmpRow = std::min( tmpRow, tmpHeight - 1 );

char *srcRowBlock = tmpBlock + dataSize * tmpRow * tmpWidth;
char *dstRowBlock = ( char * )data + dataSize * ( top + row ) * pixelWidth;
Expand All @@ -935,6 +936,7 @@ bool QgsGdalProvider::readBlock( int bandNo, QgsRectangle const &extent, int pi
{
// std::floor() is quite slow! Use just cast to int.
tmpCol = static_cast<int>( x );
tmpCol = std::min( tmpCol, tmpWidth - 1 );
if ( tmpCol > lastCol )
{
src += ( tmpCol - lastCol ) * dataSize;
Expand Down

0 comments on commit 388277e

Please sign in to comment.