summaryrefslogtreecommitdiff
path: root/gck/gck-slot.c
diff options
context:
space:
mode:
authorStef Walter <stefw@collabora.co.uk>2011-11-15 18:01:41 +0100
committerStef Walter <stefw@collabora.co.uk>2011-11-15 18:01:41 +0100
commitc20ca48b9822ff7f2128c5055d13a5abb337c354 (patch)
tree4381585539ed606b8b84e22cdcee8e911f621862 /gck/gck-slot.c
parentb22d39cf68a59189572006a21537018e6c5ab4d6 (diff)
downloadgcr-c20ca48b9822ff7f2128c5055d13a5abb337c354.tar.gz
gck: Fix problem where gck_slot_open_session_async() leaked objects
* Held a reference to the session and result, which kept the module
Diffstat (limited to 'gck/gck-slot.c')
-rw-r--r--gck/gck-slot.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/gck/gck-slot.c b/gck/gck-slot.c
index c26ed02..f55fb50 100644
--- a/gck/gck-slot.c
+++ b/gck/gck-slot.c
@@ -1025,9 +1025,11 @@ on_open_session_complete (GObject *source,
{
GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
GError *error = NULL;
+ GObject *session;
- if (g_async_initable_new_finish (G_ASYNC_INITABLE (source), result, &error))
- g_simple_async_result_set_op_res_gpointer (res, g_object_ref (source), g_object_unref);
+ session = g_async_initable_new_finish (G_ASYNC_INITABLE (source), result, &error);
+ if (session != NULL)
+ g_simple_async_result_set_op_res_gpointer (res, session, g_object_unref);
else
g_simple_async_result_take_error (res, error);
@@ -1063,6 +1065,9 @@ gck_slot_open_session_full_async (GckSlot *self,
{
GSimpleAsyncResult *res;
+ g_return_if_fail (GCK_IS_SLOT (self));
+ g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
+
res = g_simple_async_result_new (G_OBJECT (self), callback, user_data,
gck_slot_open_session_full_async);
@@ -1074,6 +1079,8 @@ gck_slot_open_session_full_async (GckSlot *self,
"opening-flags", pkcs11_flags,
"app-data", app_data,
NULL);
+
+ g_object_unref (res);
}
/**