Fix memory leak when calling endpoint method
Luiz Augusto von Dentz
maintainerPATCH v2 1/2 Fix memory leak when calling endpoint method
From: Luiz Augusto von Dentz <[email protected]>
The pending call must be unrefed in those cases
--- audio/media.c | 21 +++++++++++++++------ 1 files changed, 15 insertions(+), 6 deletions(-)
audio/media.c +15 -6
@@ -87,12 +87,23 @@ static GSList *adapters = NULL;static void endpoint_request_free (struct endpoint_request *request) {if (request->call) -dbus_pending_call_cancel (request->call); +dbus_pending_call_unref (request->call);dbus_message_unref (request->msg);g_free (request); } +static void media_endpoint_cancel (struct media_endpoint *endpoint) +{ +struct endpoint_request *request = endpoint->request; + +if (request->call) +dbus_pending_call_cancel (request->call); + +endpoint_request_free (request); + endpoint->request =NULL ; +} +static void media_endpoint_remove (struct media_endpoint *endpoint) {struct media_adapter *adapter = endpoint->adapter;
@@ -109,7 +120,7 @@ static void media_endpoint_remove(struct media_endpoint *endpoint)headset_remove_state_cb (endpoint->hs_watch);if (endpoint->request) -endpoint_request_free (endpoint->request); +media_endpoint_cancel (endpoint);if (endpoint->transport)media_transport_remove (endpoint->transport);
@@ -613,10 +624,8 @@ void media_endpoint_clear_configuration(struct media_endpoint *endpoint)if (endpoint->transport ==NULL )return ; -if (endpoint->request) { -endpoint_request_free (endpoint->request); - endpoint->request =NULL ; - } +if (endpoint->request) +media_endpoint_cancel (endpoint); conn = endpoint->adapter->conn;
Signature · 1 line
1.7.1
Hi Luiz,
Quoted 6 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
The pending call must be unrefed in those cases
--- audio/media.c | 21 +++++++++++++++------ 1 files changed, 15 insertions(+), 6 deletions(-)
Both patches have been pushed upstream. Thanks.
Johan