diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2011-10-06 14:50:32 +1100 |
---|---|---|
committer | Robert Ancell <robert.ancell@canonical.com> | 2011-10-06 14:50:32 +1100 |
commit | b646368e44d7825b09426663163f149411f50e8f (patch) | |
tree | 6a7c7dfa5819f2f2b94b6156a4c3399e8eed0d1c /src/xsession.c | |
parent | 15956eb5867fb98617028ffa374ddaec5e2a36d0 (diff) | |
download | lightdm-b646368e44d7825b09426663163f149411f50e8f.tar.gz |
Make sure objects are cleaned up on exit, Fix minor memory leaks
Diffstat (limited to 'src/xsession.c')
-rw-r--r-- | src/xsession.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/xsession.c b/src/xsession.c index 550d556f..1b61e4a2 100644 --- a/src/xsession.c +++ b/src/xsession.c @@ -35,7 +35,7 @@ XSession * xsession_new (XServer *xserver) { XSession *session = g_object_new (XSESSION_TYPE, NULL); - + session->priv->xserver = g_object_ref (xserver); return session; @@ -127,14 +127,20 @@ xsession_remove_authority (XSession *session) if (session->priv->authority_file) { gboolean drop_privileges; + gchar *path; drop_privileges = geteuid () == 0; if (drop_privileges) privileges_drop (session_get_user (SESSION (session))); - g_debug ("Removing session authority from %s", g_file_get_path (session->priv->authority_file)); + + path = g_file_get_path (session->priv->authority_file); + g_debug ("Removing session authority from %s", path); + g_free (path); xauth_write (session->priv->authority, XAUTH_WRITE_MODE_REMOVE, session->priv->authority_file, NULL); + if (drop_privileges) privileges_reclaim (); + g_object_unref (session->priv->authority_file); session->priv->authority_file = NULL; } @@ -168,6 +174,10 @@ xsession_finalize (GObject *object) xsession_remove_authority (self); if (self->priv->xserver) g_object_unref (self->priv->xserver); + if (self->priv->authority) + g_object_unref (self->priv->authority); + if (self->priv->authority_file) + g_object_unref (self->priv->authority_file); G_OBJECT_CLASS (xsession_parent_class)->finalize (object); } |