[gnome-online-accounts] todoist: 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] todoist: Avoid CRITICALs if get_identity_sync can't parse response
- Date: Wed, 2 Aug 2017 19:37:39 +0000 (UTC)
commit a5243b10523470bb661de39dd8e8f6edf8da1c22
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Aug 2 18:15:44 2017 +0200
todoist: 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/goatodoistprovider.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/src/goabackend/goatodoistprovider.c b/src/goabackend/goatodoistprovider.c
index c758a83..0995a99 100644
--- a/src/goabackend/goatodoistprovider.c
+++ b/src/goabackend/goatodoistprovider.c
@@ -213,8 +213,7 @@ get_identity_sync (GoaOAuth2Provider *oauth2_provider,
}
json_object = json_node_get_object (json_parser_get_root (parser));
- json_object_user = json_object_get_object_member (json_object, "user");
- if (json_object_user == NULL)
+ if (!json_object_has_member (json_object, "user"))
{
g_warning ("Did not find user in JSON data");
g_set_error (error,
@@ -224,8 +223,8 @@ get_identity_sync (GoaOAuth2Provider *oauth2_provider,
goto out;
}
- email = g_strdup (json_object_get_string_member (json_object_user, "email"));
- if (email == NULL)
+ json_object_user = json_object_get_object_member (json_object, "user");
+ if (!json_object_has_member (json_object_user, "email"))
{
g_warning ("Did not find email in JSON data");
g_set_error (error,
@@ -235,6 +234,8 @@ get_identity_sync (GoaOAuth2Provider *oauth2_provider,
goto out;
}
+ email = g_strdup (json_object_get_string_member (json_object_user, "email"));
+
ret = email;
email = NULL;
if (out_presentation_identity != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]