[gnome-online-accounts/wip/rishi/facebook: 8/14] flickr: 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: 8/14] flickr: Avoid CRITICALs if get_identity_sync can't parse response
- Date: Wed, 2 Aug 2017 19:21:07 +0000 (UTC)
commit e372f658034e0f0adefaf07072374833a9822697
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Aug 2 18:31:35 2017 +0200
flickr: 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/goaflickrprovider.c | 20 ++++++++++++--------
1 files changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/src/goabackend/goaflickrprovider.c b/src/goabackend/goaflickrprovider.c
index 0f2ab53..48c6721 100644
--- a/src/goabackend/goaflickrprovider.c
+++ b/src/goabackend/goaflickrprovider.c
@@ -167,8 +167,7 @@ get_identity_sync (GoaOAuthProvider *oauth_provider,
}
json_object = json_node_get_object (json_parser_get_root (parser));
- json_object = json_object_get_object_member (json_object, "user");
- if (json_object == NULL)
+ if (!json_object_has_member (json_object, "user"))
{
g_warning ("Did not find user in JSON data");
g_set_error (error,
@@ -177,8 +176,9 @@ get_identity_sync (GoaOAuthProvider *oauth_provider,
_("Could not parse response"));
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 user.id in JSON data");
g_set_error (error,
@@ -187,8 +187,7 @@ get_identity_sync (GoaOAuthProvider *oauth_provider,
_("Could not parse response"));
goto out;
}
- json_object = json_object_get_object_member (json_object, "username");
- if (json_object == NULL)
+ if (!json_object_has_member (json_object, "username"))
{
g_warning ("Did not find user.username in JSON data");
g_set_error (error,
@@ -197,8 +196,11 @@ get_identity_sync (GoaOAuthProvider *oauth_provider,
_("Could not parse response"));
goto out;
}
- presentation_identity = g_strdup (json_object_get_string_member (json_object, "_content"));
- if (presentation_identity == NULL)
+
+ id = g_strdup (json_object_get_string_member (json_object, "id"));
+
+ json_object = json_object_get_object_member (json_object, "username");
+ if (!json_object_has_member (json_object, "_content"))
{
g_warning ("Did not find user.username._content in JSON data");
g_set_error (error,
@@ -208,6 +210,8 @@ get_identity_sync (GoaOAuthProvider *oauth_provider,
goto out;
}
+ presentation_identity = g_strdup (json_object_get_string_member (json_object, "_content"));
+
ret = id;
id = NULL;
if (out_presentation_identity != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]