diff options
author | Anders Kaseorg <andersk@mit.edu> | 2014-10-08 20:01:34 +0300 |
---|---|---|
committer | Eric Koegel <eric.koegel@gmail.com> | 2014-10-08 20:01:34 +0300 |
commit | fb4d7effddc07fea51644182624d4d1c8600b975 (patch) | |
tree | 6703f4c84054ecba1ed245d8203735ded7264cc0 | |
parent | 417e387750920b9e092705863a863e71a77ea431 (diff) | |
download | ConsoleKit2-fb4d7effddc07fea51644182624d4d1c8600b975.tar.gz |
Prevent possible use-after-free condition
This patch fixes a potential use-after-free crash, because the
JobData created by ck_session_leader_collect_parameters isn’t
holding a reference to its leader.
At a minimum this presentation makes the object lifetime clearer.
Reported in:
https://bugs.freedesktop.org/show_bug.cgi?id=26227#c15
-rw-r--r-- | src/ck-session-leader.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/ck-session-leader.c b/src/ck-session-leader.c index b94f481..2ca9a68 100644 --- a/src/ck-session-leader.c +++ b/src/ck-session-leader.c @@ -408,6 +408,7 @@ job_completed (CkJob *job, static void job_data_free (JobData *data) { + g_object_unref (data->leader); g_free (data); } @@ -427,7 +428,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; |