summaryrefslogtreecommitdiff
path: root/src/agent.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2013-11-27 10:59:53 +0200
committerJohan Hedberg <johan.hedberg@intel.com>2013-11-27 10:59:53 +0200
commita2f5d438a6ed5792611ff5d34a4a0e82670a21ea (patch)
tree1e7cbcf58e3166a438c0cb8830f56ed812de5ec7 /src/agent.c
parentec1dc3134961d9626cf1402a8403ce5067dc64b0 (diff)
downloadbluez-a2f5d438a6ed5792611ff5d34a4a0e82670a21ea.tar.gz
core: Fix protecting from agent callback freeing the agent
Diffstat (limited to 'src/agent.c')
-rw-r--r--src/agent.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/agent.c b/src/agent.c
index 7880ba6a0..bcba969f4 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -319,6 +319,9 @@ static void simple_agent_reply(DBusPendingCall *call, void *user_data)
* is only called after a reply has been received */
message = dbus_pending_call_steal_reply(call);
+ /* Protect from the callback freeing the agent */
+ agent_ref(agent);
+
dbus_error_init(&err);
if (dbus_set_error_from_message(&err, message)) {
DBG("agent error reply: %s, %s", err.name, err.message);
@@ -330,6 +333,7 @@ static void simple_agent_reply(DBusPendingCall *call, void *user_data)
agent_cancel(agent);
dbus_message_unref(message);
dbus_error_free(&err);
+ agent_unref(agent);
return;
}
@@ -350,6 +354,7 @@ done:
agent->request = NULL;
agent_request_free(req, TRUE);
+ agent_unref(agent);
}
static int agent_call_authorize_service(struct agent_request *req,