[gnome-online-accounts/wip/rishi/facebook: 2/14] foursquare: Avoid CRITICALs if get_identity_sync can't parse response
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-online-accounts/wip/rishi/facebook: 2/14] foursquare: Avoid CRITICALs if get_identity_sync can't parse response
- Date: Wed, 2 Aug 2017 18:59:17 +0000 (UTC)
commit e67c30af5ea70cd61222eca4f025afcabec6df11
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Aug 2 17:44:28 2017 +0200
foursquare: Avoid CRITICALs if get_identity_sync can't parse response
The json_object_get_*_member API expects the member to be present.
Therefore, we should not use its return value to determine its
availability. Otherwise it will lead to:
Json-CRITICAL **: json_object_get_string_member: assertion
'node != NULL' failed
https://bugzilla.gnome.org/show_bug.cgi?id=785726
src/goabackend/goafoursquareprovider.c | 23 ++++++++++++-----------
1 files changed, 12 insertions(+), 11 deletions(-)
---
diff --git a/src/goabackend/goafoursquareprovider.c b/src/goabackend/goafoursquareprovider.c
index 7dc115d..be82f14 100644
--- a/src/goabackend/goafoursquareprovider.c
+++ b/src/goabackend/goafoursquareprovider.c
@@ -174,8 +174,7 @@ get_identity_sync (GoaOAuth2Provider *oauth2_provider,
}
json_object = json_node_get_object (json_parser_get_root (parser));
- json_object = json_object_get_object_member (json_object, "response");
- if (json_object == NULL)
+ if (!json_object_has_member (json_object, "response"))
{
g_warning ("Did not find response object in JSON data");
g_set_error (error,
@@ -185,8 +184,8 @@ get_identity_sync (GoaOAuth2Provider *oauth2_provider,
goto out;
}
- json_object = json_object_get_object_member (json_object, "user");
- if (json_object == NULL)
+ json_object = json_object_get_object_member (json_object, "response");
+ if (!json_object_has_member (json_object, "user"))
{
g_warning ("Did not find user object in JSON data");
g_set_error (error,
@@ -196,8 +195,8 @@ get_identity_sync (GoaOAuth2Provider *oauth2_provider,
goto out;
}
- id = g_strdup (json_object_get_string_member (json_object, "id"));
- if (id == NULL)
+ json_object = json_object_get_object_member (json_object, "user");
+ if (!json_object_has_member (json_object, "id"))
{
g_warning ("Did not find id in JSON data");
g_set_error (error,
@@ -206,9 +205,7 @@ get_identity_sync (GoaOAuth2Provider *oauth2_provider,
_("Could not parse response"));
goto out;
}
-
- json_object = json_object_get_object_member (json_object, "contact");
- if (json_object == NULL)
+ if (!json_object_has_member (json_object, "contact"))
{
g_warning ("Did not find contact object in JSON data");
g_set_error (error,
@@ -218,8 +215,10 @@ get_identity_sync (GoaOAuth2Provider *oauth2_provider,
goto out;
}
- presentation_identity = g_strdup (json_object_get_string_member (json_object, "email"));
- if (presentation_identity == NULL)
+ id = g_strdup (json_object_get_string_member (json_object, "id"));
+
+ json_object = json_object_get_object_member (json_object, "contact");
+ if (!json_object_has_member (json_object, "email"))
{
g_warning ("Did not find email in JSON data");
g_set_error (error,
@@ -229,6 +228,8 @@ get_identity_sync (GoaOAuth2Provider *oauth2_provider,
goto out;
}
+ presentation_identity = g_strdup (json_object_get_string_member (json_object, "email"));
+
ret = id;
id = NULL;
if (out_presentation_identity != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]