Skip to content

Commit

Permalink
[OAPIF provider] Avoid crash when service description page lacks emai…
Browse files Browse the repository at this point in the history
…l or url in contact object

Found when investigating OSGeo/gdal#2873
but doesn't address it
  • Loading branch information
rouault authored and nyalldawson committed Aug 22, 2020
1 parent 8496807 commit 4e0f64f
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/providers/wfs/qgsoapifapirequest.cpp
Expand Up @@ -131,17 +131,22 @@ void QgsOapifApiRequest::processReply()
if ( name.is_string() )
{
QgsAbstractMetadataBase::Contact contact( QString::fromStdString( name.get<std::string>() ) );
const auto email = jContact["email"];
if ( email.is_string() )
if ( jContact.contains( "email" ) )
{
contact.email = QString::fromStdString( email.get<std::string>() );
const auto email = jContact["email"];
if ( email.is_string() )
{
contact.email = QString::fromStdString( email.get<std::string>() );
}
}

const auto url = jContact["url"];
if ( url.is_string() )
if ( jContact.contains( "url" ) )
{
// A bit of abuse to fill organization with url
contact.organization = QString::fromStdString( url.get<std::string>() );
const auto url = jContact["url"];
if ( url.is_string() )
{
// A bit of abuse to fill organization with url
contact.organization = QString::fromStdString( url.get<std::string>() );
}
}
mMetadata.addContact( contact );
}
Expand Down

0 comments on commit 4e0f64f

Please sign in to comment.