Index: camel/camel-filter-search.c
===================================================================
--- camel/camel-filter-search.c	(revision 7928)
+++ camel/camel-filter-search.c	(working copy)
@@ -173,7 +173,7 @@
 			/* FIXME: what about Resent-To, Resent-Cc and Resent-From? */
 			if (g_ascii_strcasecmp("to", name) == 0 || g_ascii_strcasecmp("cc", name) == 0 || g_ascii_strcasecmp("from", name) == 0)
 				type = CAMEL_SEARCH_TYPE_ADDRESS_ENCODED;
-			else {
+			else if (message) {
 				ct = camel_mime_part_get_content_type (CAMEL_MIME_PART (message));
 				if (ct) {
 					charset = camel_content_type_param (ct, "charset");
Index: camel/providers/groupwise/camel-groupwise-utils.c
===================================================================
--- camel/providers/groupwise/camel-groupwise-utils.c	(revision 7928)
+++ camel/providers/groupwise/camel-groupwise-utils.c	(working copy)
@@ -626,6 +626,10 @@
 		 * and an attachment otherwise.....
 		 */
 		part = camel_multipart_get_part (mp, i);
+
+		if (!part)
+			continue;
+
 		type = camel_mime_part_get_content_type(part);
 		dw = camel_medium_get_content_object (CAMEL_MEDIUM (part));
 		
Index: camel/providers/groupwise/ChangeLog
===================================================================
--- camel/providers/groupwise/ChangeLog	(revision 7928)
+++ camel/providers/groupwise/ChangeLog	(working copy)
@@ -1,3 +1,10 @@
+2007-08-09  Milan Crha  <mcrha@redhat.com>
+
+	** Part of fix for bug #350539
+
+	* camel-groupwise-utils.c: (do_multipart):
+	Ensures non-NULL part.
+
 2007-07-30  Sankar P  <psankar@novell.com>
 
 	* camel-groupwise-folder.c: (groupwise_sync),
Index: camel/ChangeLog
===================================================================
--- camel/ChangeLog	(revision 7928)
+++ camel/ChangeLog	(working copy)
@@ -1,3 +1,14 @@
+2007-08-09  Milan Crha  <mcrha@redhat.com>
+
+	** Part of fix for bug #350539
+
+	* camel-filter-search.c: (check_header):
+	* camel-smime-context.c: (camel_smime_context_describe_part):
+	* camel-mime-part-utils.c:
+	(camel_mime_part_construct_content_from_parser):
+	* camel-gpg-context.c: (gpg_decrypt):
+	Ensures non-NULL part/message/dw/ipart/content.
+
 2007-07-28  Ross Burton  <ross@openedhand.com>
 
 	* camel-index.c:
Index: camel/camel-smime-context.c
===================================================================
--- camel/camel-smime-context.c	(revision 7928)
+++ camel/camel-smime-context.c	(working copy)
@@ -134,6 +134,9 @@
 	CamelContentType *ct;
 	const char *tmp;
 
+	if (!part)
+		return flags;
+
 	ct = camel_mime_part_get_content_type(part);
 
 	if (camel_content_type_is(ct, "multipart", "signed")) {
Index: camel/camel-mime-part-utils.c
===================================================================
--- camel/camel-mime-part-utils.c	(revision 7928)
+++ camel/camel-mime-part-utils.c	(working copy)
@@ -86,6 +86,9 @@
 	CamelContentType *ct;
 	char *encoding;
 
+	if (!dw)
+		return;
+
 	ct = camel_mime_parser_content_type (mp);
 
 	encoding = camel_content_transfer_encoding_decode (camel_mime_parser_header (mp, "Content-Transfer-Encoding", NULL));
Index: camel/camel-gpg-context.c
===================================================================
--- camel/camel-gpg-context.c	(revision 7928)
+++ camel/camel-gpg-context.c	(working copy)
@@ -1692,8 +1692,21 @@
 	CamelMultipart *mp;
 	CamelContentType *ct;
 	int rv;
-	
+
+	if (!ipart) {
+		camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+				_("Cannot decrypt message: Incorrect message format"));
+		return NULL;
+	}
+
 	content = camel_medium_get_content_object((CamelMedium *)ipart);
+
+	if (!content) {
+		camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+				_("Cannot decrypt message: Incorrect message format"));
+		return NULL;
+	}
+
 	ct = camel_mime_part_get_content_type((CamelMimePart *)content);
 	/* Encrypted part (using our fake mime type) or PGP/Mime multipart */
 	if (camel_content_type_is(ct, "multipart", "encrypted")) {	
