Skip to content
Permalink
Browse files

GDAL provider: don't crash on invalid bands

Fix unreported crash
  • Loading branch information
elpaso authored and nyalldawson committed Oct 12, 2020
1 parent afd474b commit 00ccfc8cea56bd7b896149dfa467be76d9277edc
Showing with 6 additions and 0 deletions.
  1. +6 −0 src/core/providers/gdal/qgsgdalprovider.cpp
@@ -1309,6 +1309,12 @@ QString QgsGdalProvider::generateBandName( int bandNumber ) const
}
QString generatedBandName = QgsRasterDataProvider::generateBandName( bandNumber );
GDALRasterBandH myGdalBand = getBand( bandNumber );
if ( ! myGdalBand )
{
QgsLogger::warning( QStringLiteral( "Band %1 does not exist." ).arg( bandNumber ) );
return QString();
}

QString gdalBandName( GDALGetDescription( myGdalBand ) );
if ( !gdalBandName.isEmpty() )
{

0 comments on commit 00ccfc8

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