Bug #603437 - Fixes for valgrind reports on e-calendar-factory
authorMilan Crha <mcrha@redhat.com>
Wed, 2 Dec 2009 10:36:38 +0000 (11:36 +0100)
committerMilan Crha <mcrha@redhat.com>
Wed, 2 Dec 2009 10:36:38 +0000 (11:36 +0100)
calendar/backends/groupwise/e-cal-backend-groupwise-utils.c
calendar/backends/groupwise/e-cal-backend-groupwise.c
calendar/backends/weather/e-cal-backend-weather.c
calendar/libecal/e-cal-util.c
calendar/libedata-cal/e-cal-backend-file-store.c
calendar/libedata-cal/e-data-cal.c

index f572db3..a22f377 100644 (file)
@@ -2090,8 +2090,13 @@ e_cal_backend_groupwise_store_settings (GwSettings *hold)
        kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbgw));
 
        /* TODO implement send options for Notes */
-       if (kind == ICAL_VJOURNAL_COMPONENT)
+       if (kind == ICAL_VJOURNAL_COMPONENT) {
+               g_object_unref (gconf);
+               g_object_unref (hold->opts);
+               g_free (hold);
+
                return FALSE;
+       }
 
        gopts = e_gw_sendoptions_get_general_options (opts);
        if (kind == ICAL_VEVENT_COMPONENT) {
index c78060e..3b7e15b 100644 (file)
@@ -338,7 +338,7 @@ get_deltas (gpointer handle)
        ECalBackendStore *store;
        EGwConnectionStatus status;
        icalcomponent_kind kind;
-       GList *item_list, *total_list = NULL, *l;
+       GList *item_list = NULL, *total_list = NULL, *l;
        GSList *cache_ids = NULL, *ls;
        GPtrArray *uid_array = NULL;
        gchar *time_string = NULL;
@@ -452,6 +452,7 @@ get_deltas (gpointer handle)
 
                e_cal_component_get_uid (modified_comp, &uid);
                cache_comp = e_cal_backend_store_get_component (store, uid, rid);
+               g_free (rid);
                e_cal_component_commit_sequence (modified_comp);
 
                e_cal_component_get_last_modified (modified_comp, &tt);
@@ -474,7 +475,6 @@ get_deltas (gpointer handle)
 
                        g_free (modif_comp_str);
                        g_free (cache_comp_str);
-                       g_free (rid);
                        cache_comp_str = NULL;
                        e_cal_backend_store_put_component (store, modified_comp);
                }
@@ -544,12 +544,10 @@ get_deltas (gpointer handle)
                status = e_gw_connection_read_cal_ids (cnc, cbgw->priv->container_id, cursor, FALSE, CURSOR_ICALID_LIMIT, position, &item_list);
                if (status != E_GW_CONNECTION_STATUS_OK) {
                        if (status == E_GW_CONNECTION_STATUS_NO_RESPONSE) {
-                               g_static_mutex_unlock (&connecting);
-                               return TRUE;
+                               goto err_done;
                        }
                        e_cal_backend_groupwise_notify_error_code (cbgw, status);
-                       g_static_mutex_unlock (&connecting);
-                       return TRUE;
+                       goto err_done;
                }
 
                if (!item_list  || g_list_length (item_list) == 0)
@@ -663,6 +661,7 @@ get_deltas (gpointer handle)
        g_ptr_array_foreach (uid_array, (GFunc) g_free, NULL);
        g_ptr_array_free (uid_array, TRUE);
 
+ err_done:
        if (item_list) {
                g_list_free (item_list);
                item_list = NULL;
index c8db15c..00e9d32 100644 (file)
@@ -182,6 +182,7 @@ finished_retrieval_cb (WeatherInfo *info, ECalBackendWeather *cbw)
                obj = icalcomponent_as_ical_string_r (icomp);
                e_cal_backend_notify_object_created (E_CAL_BACKEND (cbw), obj);
                g_free (obj);
+               g_object_unref (comp);
 
                forecasts = weather_info_get_forecast_list (info);
                if (forecasts) {
@@ -199,6 +200,7 @@ finished_retrieval_cb (WeatherInfo *info, ECalBackendWeather *cbw)
                                                obj = icalcomponent_as_ical_string_r (icomp);
                                                e_cal_backend_notify_object_created (E_CAL_BACKEND (cbw), obj);
                                                g_free (obj);
+                                               g_object_unref (comp);
                                        }
                                }
                        }
index e4eefb0..da32e2b 100644 (file)
@@ -123,9 +123,12 @@ e_cal_util_new_component (icalcomponent_kind kind)
 {
        icalcomponent *comp;
        struct icaltimetype dtstamp;
+       gchar *uid;
 
        comp = icalcomponent_new (kind);
-       icalcomponent_set_uid (comp, e_cal_component_gen_uid ());
+       uid = e_cal_component_gen_uid ();
+       icalcomponent_set_uid (comp, uid);
+       g_free (uid);
        dtstamp = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
        icalcomponent_set_dtstamp (comp, dtstamp);
 
index da32f56..6e7bb44 100644 (file)
@@ -637,10 +637,14 @@ scan_vcalendar (ECalBackendFileStore *fstore, icalcomponent *top_icalcomp)
 
                comp = e_cal_component_new ();
 
-               if (!e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (icalcomp)))
+               if (!e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (icalcomp))) {
+                       g_object_unref (comp);
                        continue;
+               }
 
                put_component (fstore, comp);
+
+               g_object_unref (comp);
        }
 }
 
index 10dcf37..86f0066 100644 (file)
@@ -974,7 +974,7 @@ e_data_cal_notify_free_busy (EDataCal *cal, EServerMethodContext context, EDataC
                GList *l;
                gint i;
 
-               seq = g_new0 (gchar *, g_list_length (freebusy));
+               seq = g_new0 (gchar *, g_list_length (freebusy) + 1);
                for (i = 0, l = freebusy; l; i++, l = l->next) {
                        seq[i] = g_strdup (l->data);
                }