Skip to content
Permalink
Browse files

Fix crashes when reading certain resampled raster files

TODO: completely junk this inefficient secondary resampler and use GDAL's
resampling instead

Fixes #33711
  • Loading branch information
nyalldawson committed Jan 28, 2020
1 parent df7979c commit b2c5a456fa4e9613ac33b8aaaed774ad3b7293a1
Showing with 2 additions and 0 deletions.
  1. +2 −0 src/core/providers/gdal/qgsgdalprovider.cpp
@@ -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;
@@ -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;

0 comments on commit b2c5a45

Please sign in to comment.
You can’t perform that action at this time.