Index: plugins/prefer-plain/prefer-plain.c
===================================================================
--- plugins/prefer-plain/prefer-plain.c	(revision 33968)
+++ plugins/prefer-plain/prefer-plain.c	(working copy)
@@ -66,7 +66,7 @@
 	nparts = camel_multipart_get_number(mp);	
 	for (i=0; i<nparts; i++) {
 		part = camel_multipart_get_part(mp, i);
-		if (camel_content_type_is(camel_mime_part_get_content_type(part), "text", "plain")) {
+		if (part && camel_content_type_is(camel_mime_part_get_content_type(part), "text", "plain")) {
 			displayid = i;
 			display_part = part;
 			break;
Index: plugins/prefer-plain/ChangeLog
===================================================================
--- plugins/prefer-plain/ChangeLog	(revision 33968)
+++ plugins/prefer-plain/ChangeLog	(working copy)
@@ -1,3 +1,10 @@
+2007-08-09  Milan Crha  <mcrha@redhat.com>
+
+	** Part of fix for bug #350539
+
+	* prefer-plain.c: (org_gnome_prefer_plain_multipart_alternative):
+	Ensures non-NULL part.
+
 2007-04-02  Sankar P  <psankar@novell.com>
 
 	* Committed on behalf of Gilles Dartiguelongue <dartigug@esiee.fr>
Index: plugins/audio-inline/ChangeLog
===================================================================
--- plugins/audio-inline/ChangeLog	(revision 33968)
+++ plugins/audio-inline/ChangeLog	(working copy)
@@ -1,3 +1,10 @@
+2007-08-09  Milan Crha  <mcrha@redhat.com>
+
+	** Part of fix for bug #350539
+
+	* audio-inline.c: (org_gnome_audio_inline_play_clicked):
+	Ensures non-NULL part.
+
 2006-01-09  Kjartan Maraas <kmaraas@gnome.org>
 
 	* audio-inline.c: (org_gnome_audio_inline_add_button):
Index: plugins/audio-inline/audio-inline.c
===================================================================
--- plugins/audio-inline/audio-inline.c	(revision 33968)
+++ plugins/audio-inline/audio-inline.c	(working copy)
@@ -214,14 +214,16 @@
 		d(printf ("audio inline formatter: init gst thread\n"));
 
 		if (gst_init_check (&argc, (char ***) &argv)) {
-			CamelContentType *type;
+			CamelContentType *type = NULL;
 			GstElement *filesrc;
 
 			/* create a disk reader */
 			filesrc = gst_element_factory_make ("filesrc", "disk_source");
 			g_object_set (G_OBJECT (filesrc), "location", po->filename, NULL);
 
-			type = camel_mime_part_get_content_type (po->part);
+			if (po->part)
+				type = camel_mime_part_get_content_type (po->part);
+
 			if (type) {
 				if (!g_ascii_strcasecmp (type->type, "audio")) {
 					if (!g_ascii_strcasecmp (type->subtype, "mpeg") || !g_ascii_strcasecmp (type->subtype, "x-mpeg")
Index: plugins/mail-to-task/mail-to-task.c
===================================================================
--- plugins/mail-to-task/mail-to-task.c	(revision 33968)
+++ plugins/mail-to-task/mail-to-task.c	(working copy)
@@ -131,6 +131,9 @@
 		count--;
 	}
 
+	if (!mime_part)
+		return;
+
 	type = camel_mime_part_get_content_type (mime_part);
 	if (!camel_content_type_is (type, "text", "plain"))
 		return;
Index: plugins/mail-to-task/ChangeLog
===================================================================
--- plugins/mail-to-task/ChangeLog	(revision 33968)
+++ plugins/mail-to-task/ChangeLog	(working copy)
@@ -1,3 +1,10 @@
+2007-08-09  Milan Crha  <mcrha@redhat.com>
+
+	** Part of fix for bug #350539
+
+	* mail-to-task.c: (set_description):
+	Ensures non-NULL mime_part.
+
 2007-04-02  Sankar P  <psankar@novell.com>
 
 	* Committed on behalf of Gilles Dartiguelongue <dartigug@esiee.fr>
Index: mail/ChangeLog
===================================================================
--- mail/ChangeLog	(revision 33968)
+++ mail/ChangeLog	(working copy)
@@ -1,3 +1,14 @@
+2007-08-09  Milan Crha  <mcrha@redhat.com>
+
+	** Part of fix for bug #350539
+
+	* em-format-quote.c: (emfq_format_headers), (emfq_text_plain):
+	* em-format.c: (emf_multipart_alternative), (emf_inlinepgp_signed):
+	* em-popup.c: (emp_part_popup_set_background):
+	* em-format-html.c: (efh_text_plain), (efh_message_external),
+	(efh_format_headers):
+	Ensures non-NULL part.
+
 2007-08-08  Srinivasa Ragavan  <sragavan@novell.com>
 
 	* em-folder-browser.c: (emfb_set_folder): Use the gconf key to
Index: mail/em-format-quote.c
===================================================================
--- mail/em-format-quote.c	(revision 33968)
+++ mail/em-format-quote.c	(working copy)
@@ -358,6 +358,9 @@
 	const char *charset;
 	EMFormatHeader *h;
 	
+	if (!part)
+		return;
+
 	ct = camel_mime_part_get_content_type ((CamelMimePart *) part);
 	charset = camel_content_type_param (ct, "charset");
 	charset = e_iconv_charset_name (charset);	
@@ -457,7 +460,10 @@
 	CamelContentType *type;
 	const char *format;
 	guint32 rgb = 0x737373, flags;
-	
+
+	if (!part)
+		return;
+
 	flags = emfq->text_html_flags;
 	
 	/* Check for RFC 2646 flowed text. */
Index: mail/em-format.c
===================================================================
--- mail/em-format.c	(revision 33968)
+++ mail/em-format.c	(working copy)
@@ -1243,6 +1243,10 @@
 
 		/* is it correct to use the passed in *part here? */
 		part = camel_multipart_get_part(mp, i);
+
+		if (!part)
+			continue;
+
 		type = camel_mime_part_get_content_type (part);
 		mime_type = camel_content_type_simple (type);
 		
@@ -1533,7 +1537,12 @@
 	CamelStream *ostream;
 	CamelException *ex;
 	char *type;
-	
+
+	if (!ipart) {
+		em_format_format_error(emf, stream, _("Unknown error verifying signature"));
+		return;
+	}
+
 	ex = camel_exception_new();
 	cipher = camel_gpg_context_new(emf->session);
 	/* Verify the signature of the message */
Index: mail/em-popup.c
===================================================================
--- mail/em-popup.c	(revision 33968)
+++ mail/em-popup.c	(working copy)
@@ -435,7 +435,10 @@
 		part = ((EAttachment *) ((EMPopupTargetAttachments *) t)->attachments->data)->body;
 	else
 		part = ((EMPopupTargetPart *) t)->part;
-	
+
+	if (!part)
+		return;
+
 	filename = g_strdup(camel_mime_part_get_filename(part));
 	   
 	/* if filename is blank, create a default filename based on MIME type */
Index: mail/em-format-html.c
===================================================================
--- mail/em-format-html.c	(revision 33968)
+++ mail/em-format-html.c	(working copy)
@@ -775,6 +775,9 @@
 	for (i=0;i<count;i++) {
 		CamelMimePart *newpart = camel_multipart_get_part(mp, i);
 
+		if (!newpart)
+			continue;
+
 		type = camel_mime_part_get_content_type(newpart);
 		if (camel_content_type_is (type, "text", "*") && !camel_content_type_is(type, "text", "calendar")) {
 			camel_stream_printf (stream,
@@ -899,6 +902,11 @@
 	const char *access_type;
 	char *url = NULL, *desc = NULL;
 
+	if (!part) {
+		camel_stream_printf(stream, _("Unknown external-body part."));
+		return;
+	}
+
 	/* needs to be cleaner */
 	type = camel_mime_part_get_content_type(part);
 	access_type = camel_content_type_param (type, "access-type");
@@ -1779,6 +1787,9 @@
 	char *header_sender = NULL, *header_from = NULL, *name;
 	gboolean mail_from_delegate = FALSE;
 	
+	if (!part)
+		return;
+
 	ct = camel_mime_part_get_content_type((CamelMimePart *)part);
 	charset = camel_content_type_param (ct, "charset");
 	charset = e_iconv_charset_name(charset);	
Index: composer/ChangeLog
===================================================================
--- composer/ChangeLog	(revision 33968)
+++ composer/ChangeLog	(working copy)
@@ -1,3 +1,14 @@
+2007-08-09  Milan Crha  <mcrha@redhat.com>
+
+	** Part of fix for bug #350539
+
+	* e-msg-composer-attachment.c: (e_msg_composer_attachment_edit):
+	* e-msg-composer-attachment-bar.c: (update), (attach_to_multipart):
+	* e-msg-composer.c: (add_attachments_handle_mime_part),
+	(handle_multipart_signed), (handle_multipart_alternative),
+	(handle_multipart):
+	Ensures non-NULL part.
+
 2007-08-02  Hiroyuki Ikezoe  <poincare@ikezoe.net>
 
 	** Fix for bug #462332
Index: composer/e-msg-composer-attachment.c
===================================================================
--- composer/e-msg-composer-attachment.c	(revision 33968)
+++ composer/e-msg-composer-attachment.c	(working copy)
@@ -588,7 +588,7 @@
 	dialog_data->disposition_checkbox = GTK_TOGGLE_BUTTON (
 		glade_xml_get_widget (editor_gui, "disposition_checkbox"));
 
-	if (attachment->is_available_local)	{
+	if (attachment->is_available_local && attachment->body)	{
 		set_entry (editor_gui, "file_name_entry",
 			   camel_mime_part_get_filename (attachment->body));
 		set_entry (editor_gui, "description_entry",
Index: composer/e-msg-composer-attachment-bar.c
===================================================================
--- composer/e-msg-composer-attachment-bar.c	(revision 33968)
+++ composer/e-msg-composer-attachment-bar.c	(working copy)
@@ -230,7 +230,7 @@
 		
 		attachment = p->data;
 
-		if (!attachment->is_available_local) {
+		if (!attachment->is_available_local || !attachment->body) {
 			/* stock_attach would be better, but its fugly scaled up */
 			pixbuf = e_icon_factory_get_icon("stock_unknown", E_ICON_SIZE_DIALOG);
 			if (pixbuf) {
@@ -776,7 +776,10 @@
 {
 	CamelContentType *content_type;
 	CamelDataWrapper *content;
-	
+
+	if (!attachment->body)
+		return;
+
 	content_type = camel_mime_part_get_content_type (attachment->body);
 	content = camel_medium_get_content_object (CAMEL_MEDIUM (attachment->body));
 	
Index: composer/e-msg-composer.c
===================================================================
--- composer/e-msg-composer.c	(revision 33968)
+++ composer/e-msg-composer.c	(working copy)
@@ -4169,7 +4169,10 @@
 {
 	CamelContentType *content_type;
 	CamelDataWrapper *wrapper;
-	
+
+	if (!mime_part)
+		return;
+
 	content_type = camel_mime_part_get_content_type (mime_part);
 	wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
 	
@@ -4256,6 +4259,10 @@
 	e_msg_composer_set_pgp_sign (composer, TRUE);
 	
 	mime_part = camel_multipart_get_part (multipart, CAMEL_MULTIPART_SIGNED_CONTENT);
+
+	if (!mime_part)
+		return;
+
 	content_type = camel_mime_part_get_content_type (mime_part);
 	
 	content = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
@@ -4368,6 +4375,10 @@
 		CamelMimePart *mime_part;
 		
 		mime_part = camel_multipart_get_part (multipart, i);
+
+		if (!mime_part)
+			continue;
+
 		content_type = camel_mime_part_get_content_type (mime_part);
 		content = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
 		
@@ -4422,6 +4433,10 @@
 		CamelMimePart *mime_part;
 
 		mime_part = camel_multipart_get_part (multipart, i);
+
+		if (!mime_part)
+			continue;
+
 		content_type = camel_mime_part_get_content_type (mime_part);
 		content = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
 		
Index: widgets/misc/e-attachment.c
===================================================================
--- widgets/misc/e-attachment.c	(revision 33968)
+++ widgets/misc/e-attachment.c	(working copy)
@@ -700,7 +700,7 @@
 	dialog_data->mime_type_entry = GTK_ENTRY (glade_xml_get_widget (editor_gui, "mime_type_entry"));
 	dialog_data->disposition_checkbox = GTK_TOGGLE_BUTTON (glade_xml_get_widget (editor_gui, "disposition_checkbox"));
 	
-	if (attachment->is_available_local) {
+	if (attachment->is_available_local && attachment->body) {
 		set_entry (editor_gui, "file_name_entry", camel_mime_part_get_filename (attachment->body));
 		set_entry (editor_gui, "description_entry", camel_mime_part_get_description (attachment->body));
 		content_type = camel_mime_part_get_content_type (attachment->body);
Index: widgets/misc/ChangeLog
===================================================================
--- widgets/misc/ChangeLog	(revision 33968)
+++ widgets/misc/ChangeLog	(working copy)
@@ -1,3 +1,12 @@
+2007-08-09  Milan Crha  <mcrha@redhat.com>
+
+	** Part of fix for bug #350539
+
+	* e-attachment.c: (e_attachment_edit):
+	* e-attachment-bar.c: (e_attachment_bar_create_attachment_cache),
+	(update), (attach_to_multipart):
+	Ensures non-NULL part.
+
 2007-08-06  Srinivasa Ragavan  <sragavan@novell.com>
 
 	** Fix for bug #429234
Index: widgets/misc/e-attachment-bar.c
===================================================================
--- widgets/misc/e-attachment-bar.c	(revision 33968)
+++ widgets/misc/e-attachment-bar.c	(working copy)
@@ -194,6 +194,9 @@
 
 	CamelContentType *content_type;
 
+	if (!attachment->body)
+		return;
+
 	content_type = camel_mime_part_get_content_type (attachment->body);
 
 	if (camel_content_type_is(content_type, "image", "*")) {
@@ -277,7 +280,7 @@
 		
 		attachment = priv->attachments->pdata[i];
 		
-		if (!attachment->is_available_local) {
+		if (!attachment->is_available_local || !attachment->body) {
 			/* stock_attach would be better, but its fugly scaled up */
 			if ((pixbuf = e_icon_factory_get_icon("stock_unknown", E_ICON_SIZE_DIALOG))) {
 				attachment->index = gnome_icon_list_append_pixbuf (icon_list, pixbuf, NULL, "");
@@ -1070,6 +1073,9 @@
 	CamelContentType *content_type;
 	CamelDataWrapper *content;
 	
+	if (!attachment->body)
+		return;
+
 	content_type = camel_mime_part_get_content_type (attachment->body);
 	content = camel_medium_get_content_object (CAMEL_MEDIUM (attachment->body));
 	
Index: calendar/gui/e-cal-popup.c
===================================================================
--- calendar/gui/e-cal-popup.c	(revision 33968)
+++ calendar/gui/e-cal-popup.c	(working copy)
@@ -210,7 +210,10 @@
 	CamelMimePart *part = NULL;
 
 	part = ((EAttachment *) ((ECalPopupTargetAttachments *) t)->attachments->data)->body;
-	
+
+	if (!part)
+		return;
+
 	filename = g_strdup(camel_mime_part_get_filename(part));
 	   
 	/* if filename is blank, create a default filename based on MIME type */
Index: calendar/ChangeLog
===================================================================
--- calendar/ChangeLog	(revision 33968)
+++ calendar/ChangeLog	(working copy)
@@ -1,3 +1,10 @@
+2007-08-09  Milan Crha  <mcrha@redhat.com>
+
+	** Part of fix for bug #350539
+
+	* gui/e-cal-popup.c: (ecalp_part_popup_set_background):
+	Ensures non-NULL part.
+
 2007-08-06  Milan Crha  <mcrha@redhat.com>
 
 	** Partially fix bug #401533
