diff --git a/obexd/src/manager.c b/obexd/src/manager.c
index 4c72ff6..74834f7 100644
--- a/obexd/src/manager.c
+++ b/obexd/src/manager.c
const gchar *name;
DBusError derr;
+ /* Received a reply after the agent exited */
+ if (!agent)
+ return;
+
agent->auth_pending = FALSE;
dbus_error_init(&derr);
dbus_pending_call_set_notify(call, agent_reply, NULL, NULL);
/* Workaround: process events while agent doesn't reply */
- while (agent->auth_pending)
+ while (agent && agent->auth_pending)
g_main_context_iteration(NULL, TRUE);
g_source_remove(watch);
dbus_pending_call_cancel(call);
dbus_pending_call_unref(call);
- if (!agent->new_name) {
+ if (!agent || !agent->new_name) {
return -EPERM;
}