[gnome-online-accounts] kerberos: Don't crash when an identity could not be looked up



commit f7bc7421a751b7ddeb7f2ad6e5d0a01c78f7405e
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed Aug 28 19:35:26 2013 +0200

    kerberos: Don't crash when an identity could not be looked up
    
    Set an error in look_up_identity instead of only setting the op_res to
    NULL, so that ensure_credentials_sync catches it.
    
    Hold a reference to the GoaKerberosIdentity object when queueing a
    notify. It is safer than trying to disconnect the source in dispose. We
    were not checking for all the idle sources, and even if we did, it can
    be racy if the object was getting disposed from a different thread.
    
    Fixes: https://bugzilla.gnome.org/699491

 src/goabackend/goakerberosprovider.c  |    7 +++++++
 src/goaidentity/goakerberosidentity.c |    6 ++----
 2 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/src/goabackend/goakerberosprovider.c b/src/goabackend/goakerberosprovider.c
index 6dc9f52..f051660 100644
--- a/src/goabackend/goakerberosprovider.c
+++ b/src/goabackend/goakerberosprovider.c
@@ -584,12 +584,15 @@ on_object_manager_ensured_for_look_up (GoaKerberosProvider *self,
   const char         *identifier;
   GList              *objects, *node;
   GError             *error;
+  gboolean            found;
 
   error = NULL;
+  found = FALSE;
 
   if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
                                              &error))
     {
+
       g_simple_async_result_take_error (operation_result, error);
       g_simple_async_result_complete_in_idle (operation_result);
       g_object_unref (operation_result);
@@ -629,12 +632,16 @@ on_object_manager_ensured_for_look_up (GoaKerberosProvider *self,
                                                      candidate_identity,
                                                      (GDestroyNotify)
                                                      g_object_unref);
+          found = TRUE;
           break;
         }
 
       g_object_unref (candidate_identity);
     }
 
+  if (!found)
+    g_simple_async_result_set_error (operation_result, GOA_ERROR, GOA_ERROR_FAILED, "Failed to find an 
identity");
+
   g_list_free_full (objects, (GDestroyNotify) g_object_unref);
   g_simple_async_result_complete_in_idle (G_SIMPLE_ASYNC_RESULT (operation_result));
   g_object_unref (operation_result);
diff --git a/src/goaidentity/goakerberosidentity.c b/src/goaidentity/goakerberosidentity.c
index 07787e7..e9b8c23 100644
--- a/src/goaidentity/goakerberosidentity.c
+++ b/src/goaidentity/goakerberosidentity.c
@@ -125,9 +125,6 @@ goa_kerberos_identity_dispose (GObject *object)
   g_clear_object (&self->priv->expiration_alarm);
   G_UNLOCK (identity_lock);
 
-  if (self->priv->expiration_time_idle_id != 0)
-    g_source_remove (self->priv->expiration_time_idle_id);
-
   G_OBJECT_CLASS (goa_kerberos_identity_parent_class)->dispose (object);
 
 }
@@ -509,6 +506,7 @@ static void
 clear_idle_id (NotifyRequest *request)
 {
   *request->idle_id = 0;
+  g_object_unref (request->self);
   g_slice_free (NotifyRequest, request);
 }
 
@@ -533,7 +531,7 @@ queue_notify (GoaKerberosIdentity *self,
     }
 
   request = g_slice_new0 (NotifyRequest);
-  request->self = self;
+  request->self = g_object_ref (self);
   request->idle_id = idle_id;
   request->property_name = property_name;
 


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