[evolution] Bug #667528 - Crash in pine-importer.c with no book source defined



commit df77623924aaa03cba0e861ddf840de1f2b8f28a
Author: Milan Crha <mcrha redhat com>
Date:   Mon Jan 9 14:27:53 2012 +0100

    Bug #667528 - Crash in pine-importer.c with no book source defined

 mail/importers/pine-importer.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/mail/importers/pine-importer.c b/mail/importers/pine-importer.c
index 55522d3..1ba4458 100644
--- a/mail/importers/pine-importer.c
+++ b/mail/importers/pine-importer.c
@@ -177,7 +177,7 @@ static void
 import_contacts (void)
 {
 	ESource *source;
-	ESourceList *source_list;
+	ESourceList *source_list = NULL;
 	EBookClient *book_client;
 	gchar *name;
 	GString *line;
@@ -200,10 +200,19 @@ import_contacts (void)
 	name = g_build_filename(g_get_home_dir(), ".addressbook", NULL);
 	fp = fopen(name, "r");
 	g_free (name);
-	if (fp == NULL)
+	if (fp == NULL) {
+		g_object_unref (source_list);
 		return;
+	}
 
 	source = e_source_list_peek_source_any (source_list);
+	if (!source) {
+		g_object_unref (source_list);
+		fclose (fp);
+
+		g_warning ("%s: No book source found, skipping.", G_STRFUNC);
+		return;
+	}
 
 	book_client = e_book_client_new (source, &error);
 
@@ -212,11 +221,11 @@ import_contacts (void)
 
 	g_object_unref (source_list);
 
-	if (error != NULL) {
+	if (error != NULL || !book_client) {
 		g_warning (
 			"%s: Failed to open book client: %s",
-			G_STRFUNC, error->message);
-		g_error_free (error);
+			G_STRFUNC, error ? error->message : "Unknown error");
+		g_clear_error (&error);
 		fclose (fp);
 		return;
 	}



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