[evolution-patches] Re: Patch for #68264



Hi, Rodrigo:

OK, in the process of applying the change you suggested, I discovered another
mem. leak. Patch is attached.

	Regards,
	diego

On Fri, Nov 12, 2004 at 04:42:44PM +0100, Rodrigo Moya wrote:

| On Fri, 2004-11-12 at 16:36 +0100, Diego Sevilla Ruiz wrote:
| > Hi, Rodrigo:
| > 
| > 	Ooops, sorry, my fault.  I append a patch.  I discovered also
| > two other memory leaks.
| > 
| now it looks ok, please commit, I would only change one thing:
| 
| > -       uri = e_uri_new (e_source_get_uri (t->source));
| > +        uri_text = e_source_get_uri (t->source);
| > +       uri = e_uri_new (uri_text);
| >         if ((strcmp (uri->protocol, "http") &&
| >              strcmp (uri->protocol, "webcal"))) {
| >                 e_uri_free (uri);
| > +                g_free (uri_text);
| >                 return hidden;
| >         }
| >         e_uri_free (uri);
| > +        g_free (uri_text);
| > 
| you can g_free (uri_text) right immediately after e_source_new, instead
| of free'ing it in 2 places as you do. Change it if you want when
| committing.
| -- 
| Rodrigo Moya <rodrigo novell com>

-- 
Diego Sevilla Ruiz -- http://ditec.um.es/~dsevilla/ -- dsevilla um es _.___
Dep. Ingeniería y Tecnología de Computadores, Facultad de Informática D|TEC
Univ.de Murcia,Campus Espinardo,30080 Murcia (SPAIN),Tel.+34968367571
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/plugins/calendar-http/ChangeLog,v
retrieving revision 1.4
diff -u -r1.4 ChangeLog
--- ChangeLog	12 Nov 2004 15:43:48 -0000	1.4
+++ ChangeLog	12 Nov 2004 16:14:02 -0000
@@ -4,6 +4,7 @@
 	URIs. Fixes #68264.
 	(e_calendar_http_check): Fixed a memory leak.
 	(e_calendar_http_refresh): Another mem. leak fix.
+	(e_calendar_http_url): Fixed another more memory leak.
 
 2004-11-09  Rodney Dawes  <dobey novell com>
 
Index: calendar-http.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/calendar-http/calendar-http.c,v
retrieving revision 1.2
diff -u -r1.2 calendar-http.c
--- calendar-http.c	12 Nov 2004 15:43:48 -0000	1.2
+++ calendar-http.c	12 Nov 2004 16:14:02 -0000
@@ -94,6 +94,7 @@
 	int row;
 	ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target;
 	EUri *uri;
+        char *uri_text;
 	static GtkWidget *hidden = NULL;
 
 	if (!hidden)
@@ -102,10 +103,12 @@
 	if (data->old)
 		gtk_widget_destroy (label);
 
-	uri = e_uri_new (e_source_get_uri (t->source));
+        uri_text = e_source_get_uri (t->source);
+	uri = e_uri_new (uri_text);
 	if ((strcmp (uri->protocol, "http") &&
 	     strcmp (uri->protocol, "webcal"))) {
 		e_uri_free (uri);
+                g_free (uri_text);
 		return hidden;
 	}
 	e_uri_free (uri);
@@ -121,11 +124,12 @@
 
 	entry = gtk_entry_new ();
 	gtk_widget_show (entry);
-	gtk_entry_set_text (GTK_ENTRY (entry), e_source_get_uri (t->source));
+	gtk_entry_set_text (GTK_ENTRY (entry), uri_text);
 	gtk_table_attach (GTK_TABLE (parent), entry, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
 	gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
 	g_signal_connect (G_OBJECT (entry), "changed", G_CALLBACK (url_changed), t->source);
 
+        g_free (uri_text);
 	return entry;
 }
 
@@ -229,14 +233,13 @@
 
         uri_text = e_source_get_uri (t->source);
 	uri = e_uri_new (uri_text);
+        g_free (uri_text);
 	if ((strcmp (uri->protocol, "http") &&
 	     strcmp (uri->protocol, "webcal"))) {
 		e_uri_free (uri);
-                g_free (uri_text);
 		return hidden;
 	}
 	e_uri_free (uri);
-        g_free (uri_text);
 
 	parent = data->parent;
 
@@ -295,18 +298,17 @@
 		return TRUE;
 
         uri_text = e_source_get_uri (t->source);
-        if (!strncmp (uri_text, "file:", 5))
-        {
+        if (!strncmp (uri_text, "file:", 5)) {
                 g_free (uri_text);
                 return FALSE;
         }
-        
+
 	uri = e_uri_new (uri_text);
 	ok = ((!strcmp (uri->protocol, "webcal")) ||
               (!strcmp (uri->protocol, "http")) ||
               (!strcmp (uri->protocol, "file")) );
 	e_uri_free (uri);
         g_free (uri_text);
-        
+
 	return ok;
 }


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