[Telepathy-commits] [telepathy-mission-control/master] Fix possible double free
Alberto Mardegan
alberto.mardegan at nokia.com
Tue Nov 4 06:22:20 PST 2008
When emitting the channel request failed/succeeded/cancelled event, make sure
that the channel request is still alive, before destroying it: it might have
been already destroyed, if the client disposed its weak_object.
---
libmcclient/mc-account-request.c | 19 +++++++++++++++++--
1 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/libmcclient/mc-account-request.c b/libmcclient/mc-account-request.c
index 7de600e..1daea23 100644
--- a/libmcclient/mc-account-request.c
+++ b/libmcclient/mc-account-request.c
@@ -95,6 +95,10 @@ mc_request_free (McChannelRequest *req)
static void
emit_request_event (McChannelRequest *req, McAccountChannelrequestEvent event)
{
+ McAccountChannelrequestsProps *props;
+
+ props = req->account->priv->request_props;
+
if (req->callback)
req->callback (req->account, GPOINTER_TO_UINT (req), event,
req->user_data, req->weak_object);
@@ -103,8 +107,19 @@ emit_request_event (McChannelRequest *req, McAccountChannelrequestEvent event)
event == MC_ACCOUNT_CR_FAILED ||
event == MC_ACCOUNT_CR_CANCELLED)
{
- /* the request does no longer exist */
- mc_request_free (req);
+ GList *list;
+
+ /* we must delete the request, but being careful that this might have
+ * been already done by the client, by destroying the weak_object */
+ for (list = props->requests; list != NULL; list = list->next)
+ {
+ if (req == list->data)
+ {
+ props->requests = g_list_delete_link (props->requests, list);
+ mc_request_free (req);
+ break;
+ }
+ }
}
}
--
1.5.6.5
More information about the Telepathy-commits
mailing list