[Xfce4-commits] <orage:master> 4.7.5.8: fixed memory leaks found with valgrind

Juha Kautto noreply at xfce.org
Sat Jan 2 10:42:01 CET 2010


Updating branch refs/heads/master
         to 2603fae326819c2e055af4c81f48aab3b133f998 (commit)
       from 8dfd2e88124df561b4d662f8eda3f356d6615b39 (commit)

commit 2603fae326819c2e055af4c81f48aab3b133f998
Author: Juha Kautto <juha at xfce.org>
Date:   Sat Jan 2 11:39:23 2010 +0200

    4.7.5.8: fixed memory leaks found with valgrind
    
    Analysed the code with valgrind and fixed all memory leaks found.

 configure.in.in   |    2 +-
 src/appointment.c |   10 +++++++++-
 src/ical-code.c   |    3 +--
 src/ical-expimp.c |    4 ++++
 src/interface.c   |    1 +
 src/mainbox.c     |    4 +++-
 6 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/configure.in.in b/configure.in.in
index ca88913..42636ba 100644
--- a/configure.in.in
+++ b/configure.in.in
@@ -9,7 +9,7 @@ dnl Written for Xfce by Juha Kautto <juha at xfce.org>
 dnl
 
 dnl Version information
-m4_define([orage_version], [4.7.5.7-git])
+m4_define([orage_version], [4.7.5.8-git])
 
 m4_define([gtk_minimum_version], [2.10.0])
 m4_define([xfce_minimum_version], [4.6.0])
diff --git a/src/appointment.c b/src/appointment.c
index d69c8d5..eb09665 100644
--- a/src/appointment.c
+++ b/src/appointment.c
@@ -682,6 +682,7 @@ static void on_appSound_button_clicked_cb(GtkButton *button, gpointer user_data)
         if (sound_file) {
             gtk_entry_set_text(GTK_ENTRY(apptw->Sound_entry), sound_file);
             gtk_editable_set_position(GTK_EDITABLE(apptw->Sound_entry), -1);
+            g_free(sound_file);
         }
     }
 
@@ -915,9 +916,11 @@ static gboolean fill_appt_from_apptw(xfical_appt *appt, appt_win *apptw)
         g_warning("fill_appt_from_apptw: coding error, illegal type");
 
     /* title */
+    g_free(appt->title);
     appt->title = g_strdup(gtk_entry_get_text(GTK_ENTRY(apptw->Title_entry)));
 
     /* location */
+    g_free(appt->location);
     appt->location = g_strdup(gtk_entry_get_text(
             GTK_ENTRY(apptw->Location_entry)));
 
@@ -997,6 +1000,8 @@ static gboolean fill_appt_from_apptw(xfical_appt *appt, appt_win *apptw)
             GTK_COMBO_BOX(apptw->Availability_cb));
 
     /* categories */
+    /* Note that gtk_entry_get_text returns empty string, which is not
+       the same as null, so tmp must always be freen */
     tmp = g_strdup(gtk_entry_get_text(GTK_ENTRY(apptw->Categories_entry)));
     tmp2 = gtk_combo_box_get_active_text(GTK_COMBO_BOX(apptw->Categories_cb));
     if (!strcmp(tmp2, _("Not set"))) {
@@ -1004,12 +1009,13 @@ static gboolean fill_appt_from_apptw(xfical_appt *appt, appt_win *apptw)
         tmp2 = NULL;
     }
     if (ORAGE_STR_EXISTS(tmp)) {
+        g_free(appt->categories);
         appt->categories = g_strjoin(",", tmp, tmp2, NULL);
-        g_free(tmp);
         g_free(tmp2);
     }
     else
         appt->categories = tmp2;
+    g_free(tmp);
 
     /* priority */
     appt->priority = gtk_spin_button_get_value_as_int(
@@ -1017,6 +1023,7 @@ static gboolean fill_appt_from_apptw(xfical_appt *appt, appt_win *apptw)
 
     /* notes */
     gtk_text_buffer_get_bounds(apptw->Note_buffer, &start, &end);
+    g_free(appt->note);
     appt->note = gtk_text_iter_get_text(&start, &end);
 
             /*********** ALARM TAB ***********/
@@ -2284,6 +2291,7 @@ static void fill_appt_window(appt_win *apptw, char *action, char *par)
         g_sprintf(appt->completedtime, XFICAL_APPT_TIME_FORMAT
                 , t->tm_year+1900, t->tm_mon+1 , t->tm_mday
                 , t->tm_hour, t->tm_min, 0);
+        g_free(appt->completed_tz_loc);
         appt->completed_tz_loc = g_strdup(appt->start_tz_loc);
     }
     /* we only want to enable duplication if we are working with an old
diff --git a/src/ical-code.c b/src/ical-code.c
index 2ef5851..09aef89 100644
--- a/src/ical-code.c
+++ b/src/ical-code.c
@@ -819,9 +819,7 @@ int xfical_compare_times(xfical_appt *appt)
         etime = icaltime_add(stime, duration);
         text  = icaltime_as_ical_string(etime);
         g_strlcpy(appt->endtime, text, 17);
-        /*
         g_free(appt->end_tz_loc);
-        */
         appt->end_tz_loc = g_strdup(appt->start_tz_loc);
         return(0); /* ok */
 
@@ -3283,6 +3281,7 @@ static void xfical_mark_calendar_from_component(GtkCalendar *gtkcal
         key_found = get_appt_from_icalcomponent(c, &cal_data.appt);
         icalcomponent_foreach_recurrence(c, nsdate, nedate, mark_calendar
                 , (void *)&cal_data);
+        g_free(cal_data.appt.categories);
         /*
                 , (void *)gtkcal);
         xfical_mark_calendar_days(gtkcal, year, month
diff --git a/src/ical-expimp.c b/src/ical-expimp.c
index f571a0a..9bda162 100644
--- a/src/ical-expimp.c
+++ b/src/ical-expimp.c
@@ -234,11 +234,13 @@ gboolean xfical_import_file(char *file_name)
 #endif
     ical_file_name = g_strdup_printf("%s.orage", file_name);
     if (!pre_format(file_name, ical_file_name)) {
+        g_free(ical_file_name);
         return(FALSE);
     }
     if ((file_ical = icalset_new_file(ical_file_name)) == NULL) {
         orage_message(250, P_N "Could not open ical file (%s) %s"
                 , ical_file_name, icalerror_strerror(icalerrno));
+        g_free(ical_file_name);
         return(FALSE);
     }
     for (c1 = icalset_get_first_component(file_ical);
@@ -272,10 +274,12 @@ gboolean xfical_import_file(char *file_name)
     }
     if (cnt1 == 0) {
         orage_message(150, P_N "No valid icalset components found");
+        g_free(ical_file_name);
         return(FALSE);
     }
     if (cnt2 == 0) {
         orage_message(150, P_N "No valid ical components found");
+        g_free(ical_file_name);
         return(FALSE);
     }
 
diff --git a/src/interface.c b/src/interface.c
index 996d0c9..d5bae81 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -548,6 +548,7 @@ void for_open_button_clicked(GtkButton *button, gpointer user_data)
             gtk_entry_set_text(GTK_ENTRY(intf_w->for_new_entry), cal_file);
             gtk_widget_grab_focus(intf_w->for_new_entry);
             gtk_editable_set_position(GTK_EDITABLE(intf_w->for_new_entry), -1);
+            g_free(cal_file);
         }
     }
 
diff --git a/src/mainbox.c b/src/mainbox.c
index 01de81f..501811a 100644
--- a/src/mainbox.c
+++ b/src/mainbox.c
@@ -181,8 +181,10 @@ static void mHelp_help_activate_cb(GtkMenuItem *menuitem, gpointer user_data)
            , G_DIR_SEPARATOR_S, "orage"
            , G_DIR_SEPARATOR_S, "doc"
            , G_DIR_SEPARATOR_S, "C"
-           , G_DIR_SEPARATOR_S, "orage.html", NULL);
+           , G_DIR_SEPARATOR_S, "orage.html"
+           , NULL);
     orage_exec(helpdoc, NULL, NULL);
+    g_free(helpdoc);
 }
 
 static void mHelp_about_activate_cb(GtkMenuItem *menuitem, gpointer user_data)



More information about the Xfce4-commits mailing list