diff -ur evolution-data-server-orig/camel/camel-db.c evolution-data-server-ted/camel/camel-db.c
--- evolution-data-server-orig/camel/camel-db.c	2009-10-17 18:08:43.000000000 -0500
+++ evolution-data-server-ted/camel/camel-db.c	2009-12-18 10:15:16.000000000 -0600
@@ -886,7 +886,9 @@
 
 	gint i;
 	for (i = 0; i < ncol; ++i) {
-		if (!strcmp (name [i], "uid"))
+		if (name[i] == NULL || cols[i] == NULL)
+			continue;
+		else if (!strcmp (name [i], "uid"))
 			g_ptr_array_add (data->uids, (gchar *) (camel_pstring_strdup(cols [i])));
 		else if (!strcmp (name [i], "flags"))
 			g_ptr_array_add (data->flags, GUINT_TO_POINTER(strtoul (cols [i], NULL, 10)));
@@ -933,6 +935,7 @@
 			g_ptr_array_add (array, (gchar *) (camel_pstring_strdup(cols [i])));
 	}
 	#else
+		if (cols[0] != NULL)
 			g_ptr_array_add (array, (gchar *) (camel_pstring_strdup(cols [0])));
 	#endif
 
@@ -1002,7 +1005,9 @@
 	gint i;
 
 	for (i = 0; i < ncol; ++i) {
-		if (!strcmp (name [i], "uid"))
+		if (name[i] == NULL || cols[i] == NULL)
+			continue;
+		else if (!strcmp (name [i], "uid"))
 			uid = camel_pstring_strdup(cols [i]);
 		else if (!strcmp (name [i], "preview"))
 			msg = g_strdup(cols[i]);
@@ -1060,6 +1065,7 @@
 			   g_ptr_array_add (array, (gchar *) (camel_pstring_strdup(cols [i]+8)));
 	 }
 	 #else
+	 	if (cols[0] != NULL)
 			   g_ptr_array_add (array, (gchar *) (camel_pstring_strdup(cols [0]+8)));
 	 #endif
 
@@ -1451,7 +1457,9 @@
 #else
 
 	for (i = 0; i < ncol; ++i) {
-		if (!strcmp (name [i], "folder_name"))
+		if (name[i] == NULL || cols[i] == NULL)
+			continue;
+		else if (!strcmp (name [i], "folder_name"))
 			record->folder_name = g_strdup(cols [i]);
 
 		else if (!strcmp (name [i], "version"))
diff -ur evolution-data-server-orig/camel/camel-folder-summary.c evolution-data-server-ted/camel/camel-folder-summary.c
--- evolution-data-server-orig/camel/camel-folder-summary.c	2009-10-17 18:08:43.000000000 -0500
+++ evolution-data-server-ted/camel/camel-folder-summary.c	2009-12-18 10:34:43.000000000 -0600
@@ -1119,7 +1119,9 @@
 
 	for (i = 0; i < ncol; ++i) {
 
-		if ( !strcmp (name [i], "uid") )
+		if ( name[i] == NULL || cols[i] == NULL )
+			continue;
+		else if ( !strcmp (name [i], "uid") )
 			mir->uid = (gchar *) camel_pstring_strdup (cols [i]);
 		else if ( !strcmp (name [i], "flags") )
 			mir->flags = cols [i] ? strtoul (cols [i], NULL, 10) : 0;
@@ -1184,7 +1186,7 @@
 	mir_from_cols (mir, s, ncol, cols, name);
 
 	CAMEL_SUMMARY_LOCK (s, summary_lock);
-	if (g_hash_table_lookup (s->loaded_infos, mir->uid)) {
+	if (mir->uid == NULL || g_hash_table_lookup (s->loaded_infos, mir->uid)) {
 		/* Unlock and better return*/
 		CAMEL_SUMMARY_UNLOCK (s, summary_lock);
 		camel_db_camel_mir_free (mir);
@@ -3257,6 +3259,8 @@
 
 	/* Extract User tags */
 	part = record->usertags;
+	if (part != NULL) {
+	/* No indentation to simply diff */
 	EXTRACT_FIRST_DIGIT (count)
 	for (i=0;i<count;i++) {
 		gint len;
@@ -3267,6 +3271,7 @@
 		g_free(name);
 		g_free(value);
 	}
+	}
 
 	return (CamelMessageInfo *) mi;
 }
diff -ur evolution-data-server-orig/camel/providers/imap/camel-imap-summary.c evolution-data-server-ted/camel/providers/imap/camel-imap-summary.c
--- evolution-data-server-orig/camel/providers/imap/camel-imap-summary.c	2009-10-17 18:08:43.000000000 -0500
+++ evolution-data-server-ted/camel/providers/imap/camel-imap-summary.c	2009-12-18 10:57:38.000000000 -0600
@@ -318,7 +318,8 @@
 	CamelImapMessageInfo *iinfo;
 
 	info = camel_imap_summary_parent->message_info_from_db (s, mir);
-	if (info) {
+	if (info != NULL && mir->bdata != NULL) {
+	/* We need the info, but also the flags */
 		gchar *part = g_strdup (mir->bdata), *tmp;
 		tmp = part;
 		iinfo = (CamelImapMessageInfo *)info;
