mirror of git://git.sysmocom.de/ofono
stkagent: Free pending call when destroying agent
Otherwise we leak memory and additionally D-bus invokes the method callback and since the agent is already destroyed, we segfault.
This commit is contained in:
parent
cab1dffe2b
commit
5b30157514
|
@ -127,19 +127,20 @@ void stk_agent_request_cancel(struct stk_agent *agent)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dbus_pending_call_cancel(agent->call);
|
dbus_pending_call_cancel(agent->call);
|
||||||
stk_agent_send_cancel(agent);
|
|
||||||
|
if (agent->disconnect_watch)
|
||||||
|
stk_agent_send_cancel(agent);
|
||||||
|
|
||||||
stk_agent_request_end(agent);
|
stk_agent_request_end(agent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void stk_agent_free(struct stk_agent *agent)
|
void stk_agent_free(struct stk_agent *agent)
|
||||||
{
|
{
|
||||||
DBusConnection *conn = ofono_dbus_get_connection();
|
DBusConnection *conn = ofono_dbus_get_connection();
|
||||||
gboolean busy = agent->call != NULL;
|
|
||||||
|
stk_agent_request_cancel(agent);
|
||||||
|
|
||||||
if (agent->disconnect_watch) {
|
if (agent->disconnect_watch) {
|
||||||
if (busy)
|
|
||||||
stk_agent_send_cancel(agent);
|
|
||||||
|
|
||||||
stk_agent_send_release(agent);
|
stk_agent_send_release(agent);
|
||||||
|
|
||||||
g_dbus_remove_watch(conn, agent->disconnect_watch);
|
g_dbus_remove_watch(conn, agent->disconnect_watch);
|
||||||
|
|
Loading…
Reference in New Issue