Nullify the returned data when errors occur
authorAlberto Mardegan <mardy@users.sourceforge.net>
Thu, 15 Dec 2011 14:28:43 +0000 (16:28 +0200)
committerAlberto Mardegan <mardy@users.sourceforge.net>
Thu, 15 Dec 2011 14:28:43 +0000 (16:28 +0200)
In asynchronous callbacks, we expect that the developer will not access
the returned variables if the GError is set. Language bindings, however,
might access all arguments in order to marshal them; therefore, let's
stay on the safe side and always set the data pointers to NULL.

libsignon-glib/signon-auth-service.c
libsignon-glib/signon-auth-session.c

index 2043ebf1ca8b08930244bc392ffb4ffae609df0a..65033476c116467d9505ed99c787abfcca715bd1 100644 (file)
@@ -140,7 +140,10 @@ auth_query_methods_cb (DBusGProxy *proxy, char **value,
     g_return_if_fail (data != NULL);
 
     if (error)
+    {
         new_error = _signon_errors_get_error_from_dbus (error);
+        value = NULL;
+    }
 
     (data->cb)
         (data->service, value, new_error, data->userdata);
@@ -159,7 +162,10 @@ auth_query_mechanisms_cb (DBusGProxy *proxy, char **value,
     g_return_if_fail (data != NULL);
 
     if (error)
+    {
         new_error = _signon_errors_get_error_from_dbus (error);
+        value = NULL;
+    }
 
     (data->cb)
         (data->service, data->method, value, new_error, data->userdata);
index 0474250e8710b33d92d9539e13b82c6674ca4b4e..b3a4b30f32ce83fddea9ef58fddff09b8aed966f 100644 (file)
@@ -607,7 +607,7 @@ auth_session_priv_init (SignonAuthSession *self, guint id,
 }
 
 static void
-auth_session_query_mechanisms_reply (DBusGProxy *proxy, char **object_path,
+auth_session_query_mechanisms_reply (DBusGProxy *proxy, gchar **mechanisms,
                                      GError *error, gpointer userdata)
 {
     GError *new_error = NULL;
@@ -616,10 +616,13 @@ auth_session_query_mechanisms_reply (DBusGProxy *proxy, char **object_path,
     g_return_if_fail (cb_data != NULL);
 
     if (error)
+    {
         new_error = _signon_errors_get_error_from_dbus (error);
+        mechanisms = NULL;
+    }
 
     (cb_data->cb)
-        (cb_data->self, object_path, new_error, cb_data->user_data);
+        (cb_data->self, mechanisms, new_error, cb_data->user_data);
 
     if (new_error)
         g_error_free (new_error);
@@ -638,7 +641,10 @@ auth_session_process_reply (DBusGProxy *proxy, GHashTable *session_data,
     g_return_if_fail (cb_data->self->priv != NULL);
 
     if (error)
+    {
         new_error = _signon_errors_get_error_from_dbus (error);
+        session_data = NULL;
+    }
 
     (cb_data->cb)
         (cb_data->self, session_data, new_error, cb_data->user_data);
@@ -717,7 +723,7 @@ auth_session_process_ready_cb (gpointer object, const GError *error, gpointer us
         DEBUG ("AuthSessionError: %s", err->message);
 
         (cb_data->cb)
-            (self, operation_data->session_data, err, cb_data->user_data);
+            (self, NULL, err, cb_data->user_data);
 
         if (!error)
             g_clear_error (&err);