Skip to content
Permalink
Browse files

QgsRasterLayerZonalStatsAlgorithm::processAlgorithm(): fix (likely fa…

…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 17, 2020
1 parent b292f38 commit 18a95c2c2fcd875c1ef659b48203181bb9814d63
Showing with 2 additions and 4 deletions.
  1. +2 −4 src/analysis/processing/qgsalgorithmrasterzonalstats.cpp
@@ -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() )

0 comments on commit 18a95c2

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