Re: [evolution-patches] [calendar-plugins]: fix for bug #305627



I was just looking through e-p patches and saw this patch and spotted
these things:

1)

+        url = parent_object.url;
+        uri = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
+
+        groups = e_source_list_peek_groups (pitip-> ...

camel_url_to_string () gives you a newly malloc'ed string you should
free, which you don't.

2)

+         if (!strcmp (uri, e_source_get_uri (source))) {
+                    found = TRUE;
+                    break;
+         }

e_source_get_uri () also gives you a newly malloc'ed uri which you
should free. Doing that in a loop is even worse.

Some people out there are really trying hard to to spot old leaks so we
should be very careful when writing new code, especially if we are so
close to a release. 

3)
+                CamelService parent_object;
+                CamelURL *url;
[...]
+                parent_store = folder->parent_store;
+                parent_object = parent_store->parent_object;
+                url = parent_object.url;

Really complicated code for for a simple dereference.


Attached is a patch to fix these issues. 

Yours,
Christian

P.S.: On a side note, that doesn't really look like a bug fix for me,
but more as a speed enhancement for GW although we were in feature
freeze. Oh well.
? .itip-formatter.c.swp
? .itip.patch.swp
? itip.patch
? org-gnome-itip-formatter.error
Index: itip-formatter.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/itip-formatter/itip-formatter.c,v
retrieving revision 1.49
diff -u -p -u -p -r1.49 itip-formatter.c
--- itip-formatter.c	12 Aug 2005 14:25:20 -0000	1.49
+++ itip-formatter.c	18 Aug 2005 03:12:41 -0000
@@ -1755,25 +1755,21 @@ format_itip_object (EMFormatHTML *efh, G
 
 	g_signal_connect (pitip->view, "response", G_CALLBACK (view_response_cb), pitip);
 
-	if (pitip->calendar_uid)
+	if (pitip->calendar_uid) {
 		pitip->current_ecal = start_calendar_server_by_uid (pitip, pitip->calendar_uid, pitip->type);
-	else {
+	} else {
 
 		/* Since the mailer uri matches with only groupwise calendar uri so for this case we need not 
 		   have to call find_server */
                 CamelFolder *folder;
-                CamelStore *parent_store;
-                CamelService parent_object;
                 CamelURL *url;
                 char *uri;
                 GSList *groups, *l;
-                ESource *source;
+                ESource *source = NULL;
                 gboolean found = FALSE;
 
                 folder = (((pitip->pobject).format)->format).folder;
-                parent_store = folder->parent_store;
-                parent_object = parent_store->parent_object;
-                url = parent_object.url;
+                url = CAMEL_SERVICE (folder->parent_store)->url;
                 uri = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
 
                 groups = e_source_list_peek_groups (pitip->source_lists[pitip->type]);
@@ -1781,22 +1777,26 @@ format_itip_object (EMFormatHTML *efh, G
                         ESourceGroup *group;
                         GSList *sources, *m;
 
-                        group = l->data;
+                        group = E_SOURCE_GROUP (l->data);
                         sources = e_source_group_peek_sources (group);
                         for (m = sources; m && !found; m = m->next) {
-                                source = m->data;
-                                if (!strcmp (uri, e_source_get_uri (source))) {
-                                        found = TRUE;
-                                        break;
-                                }
+				char *source_uri;
+
+				source = E_SOURCE (m->data);
+				source_uri = e_source_get_uri (source);
+				found = (strcmp (uri, source_uri) == 0);
+				g_free (source_uri);				
                         }
                 }
 
                 if (found) {
                         pitip->current_ecal = start_calendar_server (pitip, source, pitip->type, cal_opened_cb, pitip);
                         set_buttons_sensitive (pitip);
-                } else
+                } else {
                         find_server (pitip, pitip->comp);
+		}
+		
+		g_free (uri);
 	}
 	
 	return TRUE;


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