Navigation Menu

Skip to content

Commit

Permalink
[outh2] Don't crash when trying to parse an invalid json configuratio…
Browse files Browse the repository at this point in the history
…n file
  • Loading branch information
nyalldawson committed Oct 25, 2018
1 parent b5dc84d commit b8361e4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/auth/oauth2/qgsauthoauth2config.cpp
Expand Up @@ -334,7 +334,16 @@ bool QgsAuthOAuth2Config::loadConfigTxt(
QgsDebugMsg( QStringLiteral( "Error parsing JSON: %1" ).arg( QString( errStr ) ) );
return res;
}
QJsonWrapper::qvariant2qobject( variant.toMap(), this );
const QVariantMap variantMap = variant.toMap();
// safety check -- qvariant2qobject asserts if an non-matching property is found in the json
for ( QVariantMap::const_iterator iter = variantMap.constBegin(); iter != variantMap.constEnd(); ++iter )
{
QVariant property = this->property( iter.key().toLatin1() );
if ( !property.isValid() ) // e.g. not a auth config json file
return false;
}

QJsonWrapper::qvariant2qobject( variantMap, this );
break;
}
default:
Expand Down

0 comments on commit b8361e4

Please sign in to comment.