From e88e67fa2b74a25533038ade78e3787b98fd1c53 Mon Sep 17 00:00:00 2001 From: David Zeuthen Date: Sat, 4 Jul 2009 19:32:34 -0400 Subject: [PATCH] Plug a couple of memory leaks --- src/polkit/polkitunixsession.c | 24 ++++++++++++++++++------ src/polkitbackend/polkitbackendactionpool.c | 16 ++++++++-------- src/polkitbackend/polkitbackendauthority.c | 1 + 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/polkit/polkitunixsession.c b/src/polkit/polkitunixsession.c index 66c762e..968be2d 100644 --- a/src/polkit/polkitunixsession.c +++ b/src/polkit/polkitunixsession.c @@ -73,10 +73,21 @@ polkit_unix_session_init (PolkitUnixSession *unix_session) } static void +polkit_unix_session_finalize (GObject *object) +{ + PolkitUnixSession *session = POLKIT_UNIX_SESSION (object); + + g_free (session->session_id); + + if (G_OBJECT_CLASS (polkit_unix_session_parent_class)->finalize != NULL) + G_OBJECT_CLASS (polkit_unix_session_parent_class)->finalize (object); +} + +static void polkit_unix_session_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) + guint prop_id, + GValue *value, + GParamSpec *pspec) { PolkitUnixSession *session = POLKIT_UNIX_SESSION (object); @@ -94,9 +105,9 @@ polkit_unix_session_get_property (GObject *object, static void polkit_unix_session_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) + guint prop_id, + const GValue *value, + GParamSpec *pspec) { PolkitUnixSession *session = POLKIT_UNIX_SESSION (object); @@ -117,6 +128,7 @@ polkit_unix_session_class_init (PolkitUnixSessionClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + gobject_class->finalize = polkit_unix_session_finalize; gobject_class->get_property = polkit_unix_session_get_property; gobject_class->set_property = polkit_unix_session_set_property; diff --git a/src/polkitbackend/polkitbackendactionpool.c b/src/polkitbackend/polkitbackendactionpool.c index 77f52c6..b59e549 100644 --- a/src/polkitbackend/polkitbackendactionpool.c +++ b/src/polkitbackend/polkitbackendactionpool.c @@ -367,8 +367,8 @@ polkit_backend_action_pool_get_action (PolkitBackendActionPool *pool, PolkitActionDescription *ret; _PolkitActionDescription *real; ParsedAction *parsed_action; - gchar *description; - gchar *message; + const gchar *description; + const gchar *message; g_return_val_if_fail (POLKIT_BACKEND_IS_ACTION_POOL (pool), NULL); @@ -386,12 +386,12 @@ polkit_backend_action_pool_get_action (PolkitBackendActionPool *pool, goto out; } - description = g_strdup (_localize (parsed_action->localized_description, - parsed_action->description, - locale)); - message = g_strdup (_localize (parsed_action->localized_message, - parsed_action->message, - locale)); + description = _localize (parsed_action->localized_description, + parsed_action->description, + locale); + message = _localize (parsed_action->localized_message, + parsed_action->message, + locale); real = _polkit_action_description_new (action_id, description, diff --git a/src/polkitbackend/polkitbackendauthority.c b/src/polkitbackend/polkitbackendauthority.c index 8051ecf..b1a51c1 100644 --- a/src/polkitbackend/polkitbackendauthority.c +++ b/src/polkitbackend/polkitbackendauthority.c @@ -812,6 +812,7 @@ check_auth_cb (GObject *source_object, _PolkitAuthorizationResult *real_result; real_result = polkit_authorization_result_get_real (result); _polkit_authority_handle_check_authorization_finish (method_invocation, real_result); + g_object_unref (real_result); g_object_unref (result); } } -- 2.7.4