From cadd8461692659596851148ad052b3cd47ac256d Mon Sep 17 00:00:00 2001 From: Sergio Villar Senin Date: Tue, 18 Aug 2009 17:04:04 +0200 Subject: [PATCH] Fixes NB#132390, added a couple of extra checks to prevent invalid dereferences --- src/hildon2/modest-account-view-window.c | 18 +++++++++--------- src/hildon2/modest-msg-view-window.c | 11 ++++++----- src/modest-mail-operation.c | 3 ++- src/widgets/modest-attachments-view.c | 19 +++++-------------- 4 files changed, 22 insertions(+), 29 deletions(-) diff --git a/src/hildon2/modest-account-view-window.c b/src/hildon2/modest-account-view-window.c index 5253bcc..5f3eeb0 100644 --- a/src/hildon2/modest-account-view-window.c +++ b/src/hildon2/modest-account-view-window.c @@ -140,20 +140,20 @@ on_account_settings_dialog_response (GtkDialog *dialog, store_account = modest_tny_account_store_get_server_account (modest_runtime_get_account_store (), account_name, TNY_ACCOUNT_TYPE_STORE); - - /* Reconnect the store account, no need to reconnect the - transport account because it will connect when needed */ - if (tny_account_get_connection_status (store_account) == - TNY_CONNECTION_STATUS_DISCONNECTED) - tny_camel_account_set_online (TNY_CAMEL_ACCOUNT (store_account), - TRUE, NULL, NULL); - + if (store_account) { + /* Reconnect the store account, no need to reconnect the + transport account because it will connect when needed */ + if (tny_account_get_connection_status (store_account) == + TNY_CONNECTION_STATUS_DISCONNECTED) + tny_camel_account_set_online (TNY_CAMEL_ACCOUNT (store_account), + TRUE, NULL, NULL); + g_object_unref (store_account); + } /* Disconnect this handler */ g_signal_handlers_disconnect_by_func (dialog, on_account_settings_dialog_response, user_data); /* Free */ g_free (account_name); - g_object_unref (store_account); } static void diff --git a/src/hildon2/modest-msg-view-window.c b/src/hildon2/modest-msg-view-window.c index 771bd67..35781cf 100644 --- a/src/hildon2/modest-msg-view-window.c +++ b/src/hildon2/modest-msg-view-window.c @@ -3618,13 +3618,14 @@ modest_msg_view_window_reload (ModestMsgViewWindow *self) g_return_if_fail (MODEST_IS_MSG_VIEW_WINDOW (self)); priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self); - header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (self)); + header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (self)); - if (!message_reader (self, priv, header, NULL, NULL, priv->row_reference)) { - g_warning ("Shouldn't happen, trying to reload a message failed"); - } + if (header) { + if (!message_reader (self, priv, header, NULL, NULL, priv->row_reference)) + g_warning ("Shouldn't happen, trying to reload a message failed"); - g_object_unref (header); + g_object_unref (header); + } } static void diff --git a/src/modest-mail-operation.c b/src/modest-mail-operation.c index 4e1fee9..95cd33f 100644 --- a/src/modest-mail-operation.c +++ b/src/modest-mail-operation.c @@ -1282,7 +1282,8 @@ modest_mail_operation_save_to_drafts_add_msg_cb(TnyFolder *self, if (!callback_called) modest_mail_operation_notify_end (info->mailop); - g_object_unref(info->mailop); + if (info->mailop) + g_object_unref(info->mailop); g_slice_free (SaveToDraftsAddMsgInfo, info); } diff --git a/src/widgets/modest-attachments-view.c b/src/widgets/modest-attachments-view.c index f8ccd69..3fae008 100644 --- a/src/widgets/modest-attachments-view.c +++ b/src/widgets/modest-attachments-view.c @@ -150,21 +150,13 @@ modest_attachments_view_set_message (ModestAttachmentsView *attachments_view, Tn priv->selected = NULL; gtk_container_foreach (GTK_CONTAINER (priv->box), (GtkCallback) gtk_widget_destroy, NULL); - - if (priv->msg == NULL) { + + if (priv->msg == NULL) return; - } part_to_check = modest_tny_msg_get_attachments_parent (TNY_MSG (msg)); - - if (part_to_check) { - msg_content_type = modest_tny_mime_part_get_content_type (TNY_MIME_PART (part_to_check)); - is_alternate = !strcasecmp (msg_content_type, "multipart/alternative"); - } else { - /* If we couldn't find parent, just go through fallback */ - msg_content_type = NULL; - is_alternate = FALSE; - } + msg_content_type = modest_tny_mime_part_get_content_type (TNY_MIME_PART (part_to_check)); + is_alternate = !strcasecmp (msg_content_type, "multipart/alternative"); /* If the top mime part is a multipart/related, we don't show the attachments, as they're * embedded images in body */ @@ -175,7 +167,7 @@ modest_attachments_view_set_message (ModestAttachmentsView *attachments_view, Tn g_free (msg_content_type); header_content_type = modest_tny_mime_part_get_headers_content_type (TNY_MIME_PART (part_to_check)); - + if ((header_content_type != NULL) && !strstr (header_content_type, "application/")) { application_multipart = TRUE; @@ -241,7 +233,6 @@ modest_attachments_view_set_message (ModestAttachmentsView *attachments_view, Tn g_object_unref (iter); g_object_unref (parts); g_object_unref (part_to_check); - gtk_widget_queue_draw (GTK_WIDGET (attachments_view)); -- 1.7.9.5