Comment 29 for bug 232557

Revision history for this message
In , Anders Kaseorg (andersk) wrote :

(In reply to comment #14)
> Please either apply the patch, or find some other way to stop the leak.

William already applied a modified version of my patch for 0.4.2. The leak should already be gone.
http://cgit.freedesktop.org/ConsoleKit/commit/?id=7b9212fa6aff55420c58f2cacd0a941762920337

In the discussion that followed, I was just worried that his modifications introduced a potential use-after-free crash, because the JobData created by ck_session_leader_collect_parameters isn’t holding a reference to its leader. If there is no way for a CkSessionLeader to be freed with entries remaining in its pending_jobs queue (previously this was prevented by the missing unref in create_session_for_sender), then that isn’t a concern and this can be closed. Otherwise, perhaps this presentation makes it clearer why the extra ref and unref are okay?

--- a/src/ck-session-leader.c
+++ b/src/ck-session-leader.c
@@ -409,6 +409,7 @@ job_completed (CkJob *job,
 static void
 job_data_free (JobData *data)
 {
+ g_object_unref (data->leader);
         g_free (data);
 }

@@ -428,7 +429,7 @@ ck_session_leader_collect_parameters (CkSessionLeader *session_leader,
         ret = FALSE;

         data = g_new0 (JobData, 1);
- data->leader = session_leader;
+ data->leader = g_object_ref (session_leader);
         data->done_cb = done_cb;
         data->user_data = user_data;
         data->context = context;