summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2006-08-18 22:53:23 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2006-08-18 22:53:23 +0000
commit3b65dfcfae872670650113c6b103081118760a4e (patch)
tree35c7e19736b6278b6527ddc475f3604f3db041e2
parent49852c0b4fe1ef1dae5d11e7ff01b70c12464e40 (diff)
Make sure all necessaray memory is free'd when an agent exits
-rw-r--r--hcid/dbus-security.c45
1 files changed, 29 insertions, 16 deletions
diff --git a/hcid/dbus-security.c b/hcid/dbus-security.c
index 1ca2d5b1..2cc4d44b 100644
--- a/hcid/dbus-security.c
+++ b/hcid/dbus-security.c
@@ -43,24 +43,10 @@
static struct passkey_agent *default_agent = NULL;
-static void default_agent_exited(const char *name, void *data)
-{
- debug("%s exited without unregistering the default passkey agent", name);
-
- if (!default_agent || strcmp(name, default_agent->name)) {
- /* This should never happen (there's a bug in the code if it does) */
- debug("default_agent_exited: mismatch with actual default_agent");
- return;
- }
-
- free(default_agent->path);
- free(default_agent->name);
- free(default_agent);
- default_agent = NULL;
-}
-
static void passkey_agent_free(struct passkey_agent *agent)
{
+ struct slist *l;
+
if (!agent)
return;
if (agent->name)
@@ -69,9 +55,36 @@ static void passkey_agent_free(struct passkey_agent *agent)
free(agent->path);
if (agent->addr)
free(agent->addr);
+
+ for (l = agent->pending_requests; l != NULL; l = l->next) {
+ struct pending_agent_request *req = l->data;
+
+ free(req->path);
+ dbus_pending_call_cancel(req->call);
+ dbus_pending_call_unref(req->call);
+ dbus_connection_unref(req->conn);
+ free(req);
+ }
+
+ slist_free(agent->pending_requests);
+
free(agent);
}
+static void default_agent_exited(const char *name, void *data)
+{
+ debug("%s exited without unregistering the default passkey agent", name);
+
+ if (!default_agent || strcmp(name, default_agent->name)) {
+ /* This should never happen (there's a bug in the code if it does) */
+ debug("default_agent_exited: mismatch with actual default_agent");
+ return;
+ }
+
+ passkey_agent_free(default_agent);
+ default_agent = NULL;
+}
+
static struct passkey_agent *passkey_agent_new(const char *name,
const char *path, const char *addr)
{