[gnome-online-accounts] goaidentity: don't leak credentials caches



commit 89e173cf0318d383ef049187aa4c56ad089ca85e
Author: Ray Strode <rstrode redhat com>
Date:   Fri May 9 09:11:13 2014 -0400

    goaidentity: don't leak credentials caches
    
    krb5_cc_default doesn't return a shared resource, and
    the results need to be freed. Likewise,
    get_new_credentials_cache needs to be freed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=729874

 src/goaidentity/goakerberosidentitymanager.c |   33 +++++++++++---------------
 1 files changed, 14 insertions(+), 19 deletions(-)
---
diff --git a/src/goaidentity/goakerberosidentitymanager.c b/src/goaidentity/goakerberosidentitymanager.c
index f9dff19..d7f7d7c 100644
--- a/src/goaidentity/goakerberosidentitymanager.c
+++ b/src/goaidentity/goakerberosidentitymanager.c
@@ -789,12 +789,7 @@ get_new_credentials_cache (GoaKerberosIdentityManager *self,
   if (!supports_multiple_identities ||
       g_hash_table_size (self->priv->identities) == 0)
     {
-      krb5_ccache default_cache;
-
-      error_code = krb5_cc_default (self->priv->kerberos_context, &default_cache);
-
-      if (error_code == 0)
-        krb5_cc_dup (self->priv->kerberos_context, default_cache, credentials_cache);
+      error_code = krb5_cc_default (self->priv->kerberos_context, credentials_cache);
     }
   else
     {
@@ -842,20 +837,18 @@ sign_in_identity (GoaKerberosIdentityManager *self,
           g_simple_async_result_set_op_res_gpointer (operation->result, NULL, NULL);
           return;
         }
-      else
+
+      identity = goa_kerberos_identity_new (self->priv->kerberos_context,
+                                            credentials_cache,
+                                            &error);
+      krb5_cc_close (self->priv->kerberos_context, credentials_cache);
+      if (identity == NULL)
         {
-          identity = goa_kerberos_identity_new (self->priv->kerberos_context,
-                                                credentials_cache,
-                                                &error);
-          if (identity == NULL)
-            {
-              krb5_cc_close (self->priv->kerberos_context, credentials_cache);
-              g_simple_async_result_take_error (operation->result, error);
-              g_simple_async_result_set_op_res_gpointer (operation->result,
-                                                         NULL,
-                                                         NULL);
-              return;
-            }
+          g_simple_async_result_take_error (operation->result, error);
+          g_simple_async_result_set_op_res_gpointer (operation->result,
+                                                     NULL,
+                                                     NULL);
+          return;
         }
     }
   else
@@ -1462,6 +1455,8 @@ monitor_credentials_cache (GoaKerberosIdentityManager  *self,
   if (!can_monitor)
     self->priv->polling_timeout_id = g_timeout_add_seconds (FALLBACK_POLLING_INTERVAL, (GSourceFunc) 
on_polling_timeout, self);
 
+  krb5_cc_close (self->priv->kerberos_context, default_cache);
+
   return TRUE;
 }
 


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