[evolution-patches] calendar/gui/e-pub-utils.c: don't leak memory when checking if time to publish



This patch frees memory thats lost when we make a new string with
g_strdup, this is particularly bad because this function is called
periodically and could cause a big memory leak over time.

Also added a FIXME as there is some other problems here, which I handle
better in my big calendar publishing patch, if that isn't accepted I'll
submit a separate patch to make this nicer later this week.

Cheers,
Trent

-- 
Trent "Lathiat" Lloyd <trent ucc asn au>
University Computer Club
Index: calendar/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.2220
diff -u -r1.2220 ChangeLog
--- calendar/ChangeLog	29 Mar 2004 06:16:45 -0000	1.2220
+++ calendar/ChangeLog	20 Apr 2004 19:24:39 -0000
@@ -1,3 +1,9 @@
+2004-04-21  Trent Lloyd  <lathiat sixlabs org>
+
+	* gui/e-pub-utils.c: (is_publish_time) Free the old last_pub_time
+	before we make a new one with g_strdup so we don't leak memory, also
+	add a note about other memory leaks to be fixed later.
+
 2004-03-29  Kidd Wang  <kidd wang sun com>
 
 	* gui/e-calendar-view.c: (e_calendar_view_class_init): remove the
Index: calendar/gui/e-pub-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-pub-utils.c,v
retrieving revision 1.2
diff -u -r1.2 e-pub-utils.c
--- calendar/gui/e-pub-utils.c	16 Mar 2004 23:18:00 -0000	1.2
+++ calendar/gui/e-pub-utils.c	20 Apr 2004 19:24:40 -0000
@@ -20,6 +20,10 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
  */
 
+/* FIXME: Leaks memory, need to free data in allocated URI structures - my big patch
+ * for calendar publishing cleans this all up nicely, if that isnt accepted I'll submit
+ * a separate patch to fix this up later -- lathiat sixlabs org */
+
 #include <string.h>
 #include <glib.h>
 #include <gconf/gconf.h>
@@ -144,6 +148,7 @@
 		
 	} else {
 		if (strlen (uri->last_pub_time) == 0) {
+			g_free(uri->last_pub_time);
 			uri->last_pub_time = g_strdup (icaltime_as_ical_string (current_itt));
 			return TRUE;
 		}
@@ -156,6 +161,7 @@
 			case URI_PUBLISH_DAILY:
 				icaltime_adjust (&adjust_itt, 1, 0, 0, 0);
 				if (icaltime_compare_date_only (adjust_itt, current_itt ) < 0) {
+					g_free(uri->last_pub_time);
 					uri->last_pub_time = g_strdup (icaltime_as_ical_string (current_itt));
 					return TRUE;
 				}
@@ -163,6 +169,7 @@
 			case URI_PUBLISH_WEEKLY:
 				icaltime_adjust (&adjust_itt, 7, 0, 0, 0);
 				if (icaltime_compare_date_only (adjust_itt, current_itt ) < 0) {
+					g_free(uri->last_pub_time);
 					uri->last_pub_time = g_strdup (icaltime_as_ical_string (current_itt));
 					return TRUE;
 				}


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