Skip to content
Permalink
Browse files

QgsRasterChecker::runTest(): simplify error code path to avoid cppche…

…ck false positive about nullptr dereference
  • Loading branch information
rouault committed Jun 1, 2020
1 parent 9ed3f0c commit aaa7abb6d2dad35fa6dbc247124b27b7453b8792
Showing with 2 additions and 4 deletions.
  1. +2 −4 src/core/raster/qgsrasterchecker.cpp
@@ -48,19 +48,17 @@ bool QgsRasterChecker::runTest( const QString &verifiedKey, QString verifiedUri,
if ( !verifiedProvider || !verifiedProvider->isValid() )
{
error( QStringLiteral( "Cannot load provider %1 with URI: %2" ).arg( verifiedKey, verifiedUri ), mReport );
ok = false;
return false;
}

//QgsRasterDataProvider* expectedProvider = QgsRasterLayer::loadProvider( expectedKey, expectedUri );
QgsRasterDataProvider *expectedProvider = qobject_cast< QgsRasterDataProvider * >( QgsProviderRegistry::instance()->createProvider( expectedKey, expectedUri, options ) );
if ( !expectedProvider || !expectedProvider->isValid() )
{
error( QStringLiteral( "Cannot load provider %1 with URI: %2" ).arg( expectedKey, expectedUri ), mReport );
ok = false;
return false;
}

if ( !ok ) return false;

mReport += QStringLiteral( "Verified URI: %1<br>" ).arg( verifiedUri.replace( '&', QLatin1String( "&amp;" ) ) );
mReport += QStringLiteral( "Expected URI: %1<br>" ).arg( expectedUri.replace( '&', QLatin1String( "&amp;" ) ) );

0 comments on commit aaa7abb

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