[evolution-data-server] Bug #662068 - Crash in e-cal-backend-http.c:retrieval_done



commit 608fae262c7421257ef1a4d5b62724b2e24d40d5
Author: Milan Crha <mcrha redhat com>
Date:   Wed Dec 14 17:36:53 2011 +0100

    Bug #662068 - Crash in e-cal-backend-http.c:retrieval_done

 calendar/backends/http/e-cal-backend-http.c |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/calendar/backends/http/e-cal-backend-http.c b/calendar/backends/http/e-cal-backend-http.c
index 0282896..61fb4b5 100644
--- a/calendar/backends/http/e-cal-backend-http.c
+++ b/calendar/backends/http/e-cal-backend-http.c
@@ -362,6 +362,12 @@ retrieval_done (SoupSession *session,
 	GHashTable *old_cache;
 	GSList *comps_in_cache;
 
+	if (!msg || msg->status_code == SOUP_STATUS_CANCELLED) {
+		/* the backend probably gone in this case, thus just return */
+		g_object_unref (cbhttp);
+		return;
+	}
+
 	priv = cbhttp->priv;
 
 	priv->is_loading = FALSE;
@@ -370,12 +376,14 @@ retrieval_done (SoupSession *session,
 	if (!priv->uri) {
 		/* uri changed meanwhile, retrieve again */
 		begin_retrieval_cb (cbhttp);
+		g_object_unref (cbhttp);
 		return;
 	}
 
 	if (msg->status_code == SOUP_STATUS_NOT_MODIFIED) {
 		/* attempts with ETag can result in 304 status code */
 		priv->opened = TRUE;
+		g_object_unref (cbhttp);
 		return;
 	}
 
@@ -393,7 +401,7 @@ retrieval_done (SoupSession *session,
 				uri_parsed = soup_uri_new (priv->uri);
 				soup_uri_set_path (uri_parsed, newuri);
 				soup_uri_set_query (uri_parsed, NULL);
-				// g_free (newuri);
+				/* g_free (newuri); */
 
 				newuri = soup_uri_to_string (uri_parsed, FALSE);
 				g_message ("Translated URI: %s\n", newuri);
@@ -411,6 +419,7 @@ retrieval_done (SoupSession *session,
 			}
 		}
 
+		g_object_unref (cbhttp);
 		return;
 	}
 
@@ -420,6 +429,7 @@ retrieval_done (SoupSession *session,
 			if (msg->status_code == 401 || msg->status_code == 403) {
 				priv->requires_auth = TRUE;
 				e_cal_backend_notify_auth_required (E_CAL_BACKEND (cbhttp), TRUE, priv->credentials);
+				g_object_unref (cbhttp);
 				return;
 			} else
 				e_cal_backend_notify_error (E_CAL_BACKEND (cbhttp),
@@ -428,6 +438,7 @@ retrieval_done (SoupSession *session,
 		}
 
 		empty_cache (cbhttp);
+		g_object_unref (cbhttp);
 		return;
 	}
 
@@ -447,6 +458,7 @@ retrieval_done (SoupSession *session,
 		if (!priv->opened)
 			e_cal_backend_notify_error (E_CAL_BACKEND (cbhttp), _("Bad file format."));
 		empty_cache (cbhttp);
+		g_object_unref (cbhttp);
 		return;
 	}
 
@@ -455,6 +467,7 @@ retrieval_done (SoupSession *session,
 			e_cal_backend_notify_error (E_CAL_BACKEND (cbhttp), _("Not a calendar."));
 		icalcomponent_free (icalcomp);
 		empty_cache (cbhttp);
+		g_object_unref (cbhttp);
 		return;
 	}
 
@@ -537,6 +550,8 @@ retrieval_done (SoupSession *session,
 
 	priv->opened = TRUE;
 
+	g_object_unref (cbhttp);
+
 	d(g_message ("Retrieval really done.\n"));
 }
 
@@ -643,7 +658,7 @@ begin_retrieval_cb (ECalBackendHttp *cbhttp)
 	}
 
 	soup_session_queue_message (priv->soup_session, soup_message,
-				    (SoupSessionCallback) retrieval_done, cbhttp);
+				    (SoupSessionCallback) retrieval_done, g_object_ref (cbhttp));
 
 	d(g_message ("Retrieval started.\n"));
 	return FALSE;



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