Index: camel/providers/imap/camel-imap-summary.c
===================================================================
--- camel/providers/imap/camel-imap-summary.c	(revision 9191)
+++ camel/providers/imap/camel-imap-summary.c	(working copy)
@@ -40,7 +40,7 @@
 #define CAMEL_IMAP_SUMMARY_VERSION (3)
 
 #define EXTRACT_FIRST_DIGIT(val) val=strtoul (part, &part, 10);
-#define EXTRACT_DIGIT(val) part++; val=strtoul (part, &part, 10);
+#define EXTRACT_DIGIT(val) if (*part) part++; val=strtoul (part, &part, 10);
 
 static int summary_header_load (CamelFolderSummary *, FILE *);
 static int summary_header_save (CamelFolderSummary *, FILE *);
Index: camel/providers/imap/ChangeLog
===================================================================
--- camel/providers/imap/ChangeLog	(revision 9191)
+++ camel/providers/imap/ChangeLog	(working copy)
@@ -1,3 +1,11 @@
+2008-07-25  Milan Crha  <mcrha@redhat.com>
+
+	** Fix for bug #544049
+
+	* camel-imap-summary.c: (EXTRACT_DIGIT): Do not read beyond the buffer.
+	* camel-imap-folder.c: (merge_custom_flags): Pass proper pointer to
+	the 'camel_flag_set' function, otherwise it messes things.
+
 2008-07-23  Milan Crha  <mcrha@redhat.com>
 
 	** Part of fix for bug #543943
Index: camel/providers/imap/camel-imap-folder.c
===================================================================
--- camel/providers/imap/camel-imap-folder.c	(revision 9191)
+++ camel/providers/imap/camel-imap-folder.c	(working copy)
@@ -792,7 +792,7 @@ merge_custom_flags (CamelMessageInfo *mi
 			/* If this value came from the server, then add it to our local summary,
 			   otherwise it was in local summary, but isn't on the server, thus remove it. */
 			changed = TRUE;
-			camel_flag_set (mi, p->data, g_hash_table_lookup (server, p->data) != NULL);
+			camel_flag_set (&((CamelMessageInfoBase *)mi)->user_flags, p->data, g_hash_table_lookup (server, p->data) != NULL);
 			((CamelMessageInfoBase *) mi)->flags |= CAMEL_MESSAGE_FOLDER_FLAGGED;
 		}
 	}
Index: camel/ChangeLog
===================================================================
--- camel/ChangeLog	(revision 9192)
+++ camel/ChangeLog	(working copy)
@@ -1,3 +1,9 @@
+2008-07-25  Milan Crha  <mcrha@redhat.com>
+
+	** Part of fix for bug #544049
+
+	* camel-object.c: Initialize global variables, just to be sure.
+
 2008-07-25  Milan Crha  <mcrha@redhat.com>
 
 	** Fix for bug #544651
Index: camel/camel-object.c
===================================================================
--- camel/camel-object.c	(revision 9191)
+++ camel/camel-object.c	(working copy)
@@ -142,8 +142,8 @@ static GMutex *ref_lock;
 static GHashTable *type_table;
 
 /* fundamental types are accessed via global */
-CamelType camel_object_type;
-CamelType camel_interface_type;
+CamelType camel_object_type = CAMEL_INVALID_TYPE;
+CamelType camel_interface_type = CAMEL_INVALID_TYPE;
 
 #define P_LOCK(l) (pthread_mutex_lock(&l))
 #define P_UNLOCK(l) (pthread_mutex_unlock(&l))
