From ba502c8537841a9b40dc2b6b7f17a914d81ed6d5 Mon Sep 17 00:00:00 2001 From: Eric Koegel Date: Sun, 10 May 2015 09:55:11 +0300 Subject: CkSession: Fix error handling in dbus_activate Since we set an initial error message in the event g_signal_emit isn't handled for the session activate signal, we need to keep track of that error message. Additionally, that signal call may return a different error message such as the session is already activate on the seat so we need to keep track of both since we'll need to free the memory associated with them. --- src/ck-session.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ck-session.c b/src/ck-session.c index f8dd14b..6836146 100644 --- a/src/ck-session.c +++ b/src/ck-session.c @@ -449,7 +449,8 @@ static gboolean dbus_activate (ConsoleKitSession *cksession, GDBusMethodInvocation *context) { - GError *error; + GError *error = NULL; + GError *initial_error; CkSession *session = CK_SESSION (cksession); TRACE (); @@ -460,6 +461,10 @@ dbus_activate (ConsoleKitSession *cksession, g_set_error (&error, CK_SESSION_ERROR, CK_SESSION_ERROR_NOT_SUPPORTED, _("Activate signal not handeled. Session not attached to seat, or the seat doesn't support activation changes")); + /* keep track of the starting error because the call to g_signal_emit + * may change it and we still need to free it */ + initial_error = error; + g_signal_emit (session, signals [ACTIVATE], 0, context, &error); if (error != NULL) { /* if the signal is not handled then either: @@ -478,9 +483,14 @@ dbus_activate (ConsoleKitSession *cksession, default: throw_error (context, CK_SESSION_ERROR_GENERAL, error->message); } + + g_clear_error (&error); + g_clear_error (&initial_error); return TRUE; } + g_clear_error (&initial_error); + console_kit_session_complete_activate (cksession, context); return TRUE; } -- cgit v1.2.3