Skip to content

Commit

Permalink
QgsRasterLayerZonalStatsAlgorithm::processAlgorithm(): fix (likely fa…
Browse files Browse the repository at this point in the history
…lse positive) nullPointer cppcheck warning

cppcheck warned about potential null pointer dereference of rasterBlock and
zonesRasterBlock at line 242
```
if ( !rasterBlock->isValid() || rasterBlock->isEmpty() || !zonesRasterBlock->isValid() || zonesRasterBlock->isEmpty() )
```

It is likely that the logic about correctly prevented those null pointer from
arising, but this wasn't immediately obvious. Make it so
  • Loading branch information
rouault authored and nyalldawson committed May 19, 2020
1 parent b292f38 commit 18a95c2
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/analysis/processing/qgsalgorithmrasterzonalstats.cpp
Expand Up @@ -225,18 +225,16 @@ QVariantMap QgsRasterLayerZonalStatsAlgorithm::processAlgorithm( const QVariantM
break;

zonesRasterBlock.reset( mZonesInterface->block( mZonesBand, blockExtent, iterCols, iterRows ) );
if ( !zonesRasterBlock )
continue;
}
else
{
if ( !iter.readNextRasterPart( mZonesBand, iterCols, iterRows, zonesRasterBlock, iterLeft, iterTop, &blockExtent ) )
break;

rasterBlock.reset( mSourceInterface->block( mBand, blockExtent, iterCols, iterRows ) );
if ( !rasterBlock )
continue;
}
if ( !zonesRasterBlock || !rasterBlock )
continue;

feedback->setProgress( 100 * ( ( iterTop / maxHeight * nbBlocksWidth ) + iterLeft / maxWidth ) / nbBlocks );
if ( !rasterBlock->isValid() || rasterBlock->isEmpty() || !zonesRasterBlock->isValid() || zonesRasterBlock->isEmpty() )
Expand Down

0 comments on commit 18a95c2

Please sign in to comment.