Skip to content
Permalink
Browse files

[outh2] Don't crash when trying to parse an invalid json configuratio…

…n file
  • Loading branch information
nyalldawson committed Oct 24, 2018
1 parent b5dc84d commit b8361e4f9e70afb70e24cbc6f1dddc402f1fd25f
Showing with 10 additions and 1 deletion.
  1. +10 −1 src/auth/oauth2/qgsauthoauth2config.cpp
@@ -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:

0 comments on commit b8361e4

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