Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] Fix some crashes on invalid parameters
  • Loading branch information
nyalldawson committed May 15, 2018
1 parent 74b0e91 commit a0ff2af
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/analysis/processing/qgsalgorithmextractbylocation.cpp
Expand Up @@ -349,7 +349,12 @@ QgsExtractByLocationAlgorithm *QgsExtractByLocationAlgorithm::createInstance() c
QVariantMap QgsExtractByLocationAlgorithm::processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
{
std::unique_ptr< QgsFeatureSource > input( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) );
if ( !input )
throw QgsProcessingException( invalidSourceError( parameters, QStringLiteral( "INPUT" ) ) );
std::unique_ptr< QgsFeatureSource > intersectSource( parameterAsSource( parameters, QStringLiteral( "INTERSECT" ), context ) );
if ( !intersectSource )
throw QgsProcessingException( invalidSourceError( parameters, QStringLiteral( "INTERSECT" ) ) );

const QList< int > selectedPredicates = parameterAsEnums( parameters, QStringLiteral( "PREDICATE" ), context );
QString dest;
std::unique_ptr< QgsFeatureSink > sink( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest, input->fields(), input->wkbType(), input->sourceCrs() ) );
Expand Down
2 changes: 2 additions & 0 deletions src/analysis/processing/qgsalgorithmfiledownloader.cpp
Expand Up @@ -71,6 +71,8 @@ QVariantMap QgsFileDownloaderAlgorithm::processAlgorithm( const QVariantMap &par
{
mFeedback = feedback;
QString url = parameterAsString( parameters, QStringLiteral( "URL" ), context );
if ( url.isEmpty() )
throw QgsProcessingException( tr( "No URL specified" ) );
QString outputFile = parameterAsFileOutput( parameters, QStringLiteral( "OUTPUT" ), context );

QEventLoop loop;
Expand Down
2 changes: 2 additions & 0 deletions src/analysis/processing/qgsalgorithmsaveselectedfeatures.cpp
Expand Up @@ -69,6 +69,8 @@ QgsSaveSelectedFeatures *QgsSaveSelectedFeatures::createInstance() const
QVariantMap QgsSaveSelectedFeatures::processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
{
QgsVectorLayer *selectLayer = parameterAsVectorLayer( parameters, QStringLiteral( "INPUT" ), context );
if ( !selectLayer )
throw QgsProcessingException( invalidSourceError( parameters, QStringLiteral( "INPUT" ) ) );

QString dest;
std::unique_ptr< QgsFeatureSink > sink( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest, selectLayer->fields(), selectLayer->wkbType(), selectLayer->sourceCrs() ) );
Expand Down

0 comments on commit a0ff2af

Please sign in to comment.