[evolution-couchdb] Only set revision for documents we have an ID for, avoiding crashes on g_hash_table_lookup



commit 496ff018dc36549da2423ae45902d1b64fccea63
Author: Rodrigo Moya <rodrigo gnome-db org>
Date:   Thu Jan 13 16:13:38 2011 +0100

    Only set revision for documents we have an ID for, avoiding crashes on g_hash_table_lookup

 addressbook/e-book-backend-couchdb.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/addressbook/e-book-backend-couchdb.c b/addressbook/e-book-backend-couchdb.c
index 7240942..7843072 100644
--- a/addressbook/e-book-backend-couchdb.c
+++ b/addressbook/e-book-backend-couchdb.c
@@ -734,12 +734,13 @@ couch_document_from_contact (EBookBackendCouchDB *couchdb_backend, EContact *con
 	document = couchdb_document_contact_new ();
 
 	str = e_contact_get_const (contact, E_CONTACT_UID);
-	if (str != NULL)
+	if (str != NULL) {
 		couchdb_document_set_id (COUCHDB_DOCUMENT (document), str);
 
-	str = g_hash_table_lookup (couchdb_backend->revisions, e_contact_get_const (contact, E_CONTACT_UID));
-	if (str != NULL)
-		couchdb_document_set_revision (COUCHDB_DOCUMENT (document), str);
+		str = g_hash_table_lookup (couchdb_backend->revisions, str);
+		if (str != NULL)
+			couchdb_document_set_revision (COUCHDB_DOCUMENT (document), str);
+	}
 
 	contact_name = (EContactName *) e_contact_get (contact, E_CONTACT_NAME);
 	if (contact_name != NULL) {



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