[evolution-patches] e-book-backend-sync patch



This fixes warnings/crashes when the backend implementation returns an
error instead of data.


Index: addressbook/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/ChangeLog,v
retrieving revision 1.113
diff -u -r1.113 ChangeLog
--- addressbook/ChangeLog	31 Mar 2004 22:42:26 -0000	1.113
+++ addressbook/ChangeLog	1 Apr 2004 15:39:52 -0000
@@ -1,3 +1,14 @@
+2004-04-01  Dan Winship  <danw ximian com>
+
+	* libedata-book/e-book-backend-sync.c
+	(_e_book_backend_create_contact,
+	_e_book_backend_remove_contacts,
+	_e_book_backend_modify_contact,
+	_e_book_backend_get_contact,
+	_e_book_backend_get_supported_fields,
+	_e_book_backend_get_supported_auth_methods): Don't try to free the
+	returned data if the method didn't actually return anything
+
 2004-03-30  Chris Toshok  <toshok ximian com>
  
 	[ backend portion of fix for #51977 ]
Index: addressbook/libedata-book/e-book-backend-sync.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/libedata-book/e-book-backend-sync.c,v
retrieving revision 1.2
diff -u -r1.2 e-book-backend-sync.c
--- addressbook/libedata-book/e-book-backend-sync.c	10 Nov 2003 17:12:13 -0000	1.2
+++ addressbook/libedata-book/e-book-backend-sync.c	1 Apr 2004 15:39:52 -0000
@@ -194,13 +194,14 @@
 				const char *vcard)
 {
 	EBookBackendSyncStatus status;
-	EContact *contact;
+	EContact *contact = NULL;
 
 	status = e_book_backend_sync_create_contact (E_BOOK_BACKEND_SYNC (backend), book, vcard, &contact);
 
 	e_data_book_respond_create (book, status, contact);
 
-	g_object_unref (contact);
+	if (contact)
+		g_object_unref (contact);
 }
 
 static void
@@ -215,7 +216,8 @@
 
 	e_data_book_respond_remove_contacts (book, status, ids);
 
-	g_list_free (ids);
+	if (ids)
+		g_list_free (ids);
 }
 
 static void
@@ -224,13 +226,14 @@
 				const char *vcard)
 {
 	EBookBackendSyncStatus status;
-	EContact *contact;
+	EContact *contact = NULL;
 
 	status = e_book_backend_sync_modify_contact (E_BOOK_BACKEND_SYNC (backend), book, vcard, &contact);
 
 	e_data_book_respond_modify (book, status, contact);
 
-	g_object_unref (contact);
+	if (contact)
+		g_object_unref (contact);
 }
 
 static void
@@ -239,13 +242,14 @@
 			     const char *id)
 {
 	EBookBackendSyncStatus status;
-	char *vcard;
+	char *vcard = NULL;
 
 	status = e_book_backend_sync_get_contact (E_BOOK_BACKEND_SYNC (backend), book, id, &vcard);
 
 	e_data_book_respond_get_contact (book, status, vcard);
 
-	g_free (vcard);
+	if (vcard)
+		g_free (vcard);
 }
 
 static void
@@ -301,8 +305,10 @@
 
 	e_data_book_respond_get_supported_fields (book, status, fields);
 
-	g_list_foreach (fields, (GFunc)g_free, NULL);
-	g_list_free (fields);
+	if (fields) {
+		g_list_foreach (fields, (GFunc)g_free, NULL);
+		g_list_free (fields);
+	}
 }
 
 static void
@@ -316,8 +322,10 @@
 
 	e_data_book_respond_get_supported_auth_methods (book, status, methods);
 
-	g_list_foreach (methods, (GFunc)g_free, NULL);
-	g_list_free (methods);
+	if (methods) {
+		g_list_foreach (methods, (GFunc)g_free, NULL);
+		g_list_free (methods);
+	}
 }
 
 static void


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