From 7d706daf3ef003e0e7cb5a30296df2e1a1c65ee3 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Wed, 18 Feb 2015 17:06:46 +0100 Subject: [PATCH] agent-manager: memleak: unref the last agent for a request too ==29353== 620 (+620) (32 (+32) direct, 588 (+588) indirect) bytes in 1 (+1) blocks are definitely lost in loss record 6,905 of 7,076 ==29353== at 0x7CDBAC8: g_type_create_instance (gtype.c:1844) ==29353== by 0x7CBF356: g_object_new_internal (gobject.c:1774) ==29353== by 0x7CC0D4C: g_object_newv (gobject.c:1922) ==29353== by 0x7CC14E3: g_object_new (gobject.c:1614) ==29353== by 0x50B58A: nm_secret_agent_new (nm-secret-agent.c:489) ==29353== by 0x50915F: impl_agent_manager_register_with_capabilities (nm-agent-manager.c:309) ==29353== by 0x62649BE: invoke_object_method (dbus-gobject.c:1899) ==29353== by 0x62649BE: object_registration_message (dbus-gobject.c:2161) ==29353== by 0x649D5CE: _dbus_object_tree_dispatch_and_unlock (dbus-object-tree.c:1018) ==29353== by 0x648F193: dbus_connection_dispatch (dbus-connection.c:4718) ==29353== by 0x6261DB4: message_queue_dispatch (dbus-gmain.c:90) ==29353== by 0x7F44AEA: g_main_dispatch (gmain.c:3111) ==29353== by 0x7F44AEA: g_main_context_dispatch (gmain.c:3710) ==29353== by 0x7F44E87: g_main_context_iterate.isra.29 (gmain.c:3781) --- src/settings/nm-agent-manager.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/settings/nm-agent-manager.c b/src/settings/nm-agent-manager.c index 6228dd5adb..99602d9483 100644 --- a/src/settings/nm-agent-manager.c +++ b/src/settings/nm-agent-manager.c @@ -318,6 +318,7 @@ impl_agent_manager_register_with_capabilities (NMAgentManager *self, priv->chains = g_slist_append (priv->chains, chain); } else { + g_object_unref (agent); error = g_error_new_literal (NM_AGENT_MANAGER_ERROR, NM_AGENT_MANAGER_ERROR_FAILED, "Unable to start agent authentication."); @@ -585,11 +586,12 @@ request_next_agent (Request *req) { GError *error = NULL; + req->current_call_id = NULL; + if (req->current) + g_object_unref (req->current); + if (req->pending) { /* Send the request to the next agent */ - req->current_call_id = NULL; - if (req->current) - g_object_unref (req->current); req->current = req->pending->data; req->pending = g_slist_remove (req->pending, req->current); @@ -599,7 +601,6 @@ request_next_agent (Request *req) req->next_callback (req); } else { - req->current_call_id = NULL; req->current = NULL; /* No more secret agents are available to fulfill this secrets request */