[evolution-ews] Fix a corner case for a leak fix from bug #665801



commit 11c1acd562731c9eddb89898fbd7b46d18c732c1
Author: Milan Crha <mcrha redhat com>
Date:   Wed Mar 14 20:55:42 2012 +0100

    Fix a corner case for a leak fix from bug #665801

 src/server/e-ews-connection.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/src/server/e-ews-connection.c b/src/server/e-ews-connection.c
index 1432647..57009b9 100644
--- a/src/server/e-ews-connection.c
+++ b/src/server/e-ews-connection.c
@@ -1257,6 +1257,7 @@ autodiscover_response_cb (SoupSession *session,
 	xmlNode *node;
 	gint idx;
 	gboolean success = FALSE;
+	GSimpleAsyncResult *simple;
 
 	for (idx = 0; idx < 4; idx++) {
 		if (ad->msgs[idx] == msg)
@@ -1269,6 +1270,13 @@ autodiscover_response_cb (SoupSession *session,
 
 	ad->msgs[idx] = NULL;
 
+	/* Take 'simple' from 'ad' before actual call
+	   to g_simple_async_result_complete_in_idle(),
+	   for cases where the 'ad' is freed in autodiscover_done_cb()
+	   before this function finishes. Suggested by Dan Winship.
+	*/
+	simple = ad->simple;
+
 	if (status != 200) {
 		g_set_error (
 			     &error, EWS_CONNECTION_ERROR,
@@ -1352,7 +1360,7 @@ autodiscover_response_cb (SoupSession *session,
 
 	g_simple_async_result_set_op_res_gpointer (ad->simple, urls, NULL);
 	g_simple_async_result_complete_in_idle (ad->simple);
-	g_object_unref (ad->simple);
+	g_object_unref (simple);
 	return;
 
 failed:
@@ -1371,7 +1379,7 @@ failed:
 	 * want the *first* error */
 	g_simple_async_result_set_from_error (ad->simple, error);
 	g_simple_async_result_complete_in_idle (ad->simple);
-	g_object_unref (ad->simple);
+	g_object_unref (simple);
 }
 
 static void post_restarted (SoupMessage *msg, gpointer data)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]