[gnome-online-accounts/wip/rishi/facebook: 1/4] lastfm: Avoid CRITICALs if lastfm_login_sync can't parse response



commit 20884564fa6acd76493291e1d3d6b5bac25e55d5
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed Aug 2 17:59:31 2017 +0200

    lastfm: Avoid CRITICALs if lastfm_login_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/goalastfmprovider.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/src/goabackend/goalastfmprovider.c b/src/goabackend/goalastfmprovider.c
index ac07e66..98b979c 100644
--- a/src/goabackend/goalastfmprovider.c
+++ b/src/goabackend/goalastfmprovider.c
@@ -223,16 +223,19 @@ lastfm_login_sync (GoaProvider                  *provider,
 
   root = json_parser_get_root (parser);
   json_obj = json_node_get_object (root);
-  session_obj = json_node_get_object (json_object_get_member (json_obj, "session"));
-
-  if (json_object_get_string_member (session_obj, "name") == NULL)
+  if (!json_object_has_member (json_obj, "session"))
     {
       g_set_error (error, GOA_ERROR, GOA_ERROR_FAILED, _("Could not parse response"));
       goto out;
     }
 
-
-  if (json_object_get_string_member (session_obj, "key") == NULL)
+  session_obj = json_node_get_object (json_object_get_member (json_obj, "session"));
+  if (!json_object_has_member (session_obj, "name"))
+    {
+      g_set_error (error, GOA_ERROR, GOA_ERROR_FAILED, _("Could not parse response"));
+      goto out;
+    }
+  if (!json_object_has_member (session_obj, "key"))
     {
       g_set_error (error, GOA_ERROR, GOA_ERROR_FAILED, _("Could not parse response"));
       goto out;


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