[evolution] Bug #603480 - [bbdb] Crash on unref of uninitialized memory



commit 7befe13bd00e32a181644cb1fa3349afaf4eff58
Author: Milan Crha <mcrha redhat com>
Date:   Tue Jan 19 15:06:23 2010 +0100

    Bug #603480 - [bbdb] Crash on unref of uninitialized memory
    
    after address book error

 plugins/bbdb/bbdb.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/plugins/bbdb/bbdb.c b/plugins/bbdb/bbdb.c
index a9056b1..d9b1967 100644
--- a/plugins/bbdb/bbdb.c
+++ b/plugins/bbdb/bbdb.c
@@ -313,7 +313,8 @@ bbdb_do_it (EBook *book, const gchar *name, const gchar *email)
 {
 	gchar *query_string, *delim, *temp_name = NULL;
 	EBookQuery *query;
-	GList *contacts, *l;
+	GList *contacts = NULL, *l;
+	gboolean status;
 	EContact *contact;
 	GError *error = NULL;
 
@@ -336,10 +337,10 @@ bbdb_do_it (EBook *book, const gchar *name, const gchar *email)
 	query = e_book_query_from_string (query_string);
 	g_free (query_string);
 
-	e_book_get_contacts (book, query, &contacts, NULL);
+	status = e_book_get_contacts (book, query, &contacts, NULL);
 	if (query)
 		e_book_query_unref (query);
-	if (contacts != NULL) {
+	if (contacts != NULL || !status) {
 		for (l = contacts; l != NULL; l = l->next)
 			g_object_unref ((GObject *)l->data);
 		g_list_free (contacts);
@@ -365,15 +366,15 @@ bbdb_do_it (EBook *book, const gchar *name, const gchar *email)
 	query = e_book_query_from_string (query_string);
 	g_free (query_string);
 
-	e_book_get_contacts (book, query, &contacts, NULL);
+	status = e_book_get_contacts (book, query, &contacts, NULL);
 	if (query)
 		e_book_query_unref (query);
-	if (contacts != NULL) {
+	if (contacts != NULL || !status) {
 
 		/* FIXME: If there's more than one contact with this
 		   name, just give up; we're not smart enough for
 		   this. */
-		if (contacts->next != NULL) {
+		if (!status || contacts->next != NULL) {
 			for (l = contacts; l != NULL; l = l->next)
 				g_object_unref ((GObject *)l->data);
 			g_list_free (contacts);



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