[gnome-online-accounts/wip/rishi/facebook: 3/14] google: Avoid CRITICALs if get_identity_sync can't parse response



commit 09c8426a367392bdabd9432d5e1f0a123dbe0279
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed Aug 2 17:45:54 2017 +0200

    google: Avoid CRITICALs if get_identity_sync can't parse response
    
    The json_object_get_string_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/goagoogleprovider.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/src/goabackend/goagoogleprovider.c b/src/goabackend/goagoogleprovider.c
index 42a177a..5510553 100644
--- a/src/goabackend/goagoogleprovider.c
+++ b/src/goabackend/goagoogleprovider.c
@@ -211,8 +211,7 @@ get_identity_sync (GoaOAuth2Provider  *oauth2_provider,
     }
 
   json_object = json_node_get_object (json_parser_get_root (parser));
-  email = g_strdup (json_object_get_string_member (json_object, "email"));
-  if (email == NULL)
+  if (!json_object_has_member (json_object, "email"))
     {
       g_warning ("Did not find email in JSON data");
       g_set_error (error,
@@ -222,6 +221,7 @@ get_identity_sync (GoaOAuth2Provider  *oauth2_provider,
       goto out;
     }
 
+  email = g_strdup (json_object_get_string_member (json_object, "email"));
 
   ret = email;
   email = NULL;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]