Fixes NB#132390, added a couple of extra checks to prevent invalid dereferences
authorSergio Villar Senin <svillar@igalia.com>
Tue, 18 Aug 2009 15:04:04 +0000 (17:04 +0200)
committerSergio Villar Senin <svillar@igalia.com>
Tue, 18 Aug 2009 15:11:46 +0000 (17:11 +0200)
src/hildon2/modest-account-view-window.c
src/hildon2/modest-msg-view-window.c
src/modest-mail-operation.c
src/widgets/modest-attachments-view.c

index 5253bcc..5f3eeb0 100644 (file)
@@ -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);
        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);
        /* 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
 }
 
 static void
index 771bd67..35781cf 100644 (file)
@@ -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);
        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
 }
 
 static void
index 4e1fee9..95cd33f 100644 (file)
@@ -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);
 
        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);
 }
 
        g_slice_free (SaveToDraftsAddMsgInfo, info);
 }
 
index f8ccd69..3fae008 100644 (file)
@@ -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);
        priv->selected = NULL;
 
        gtk_container_foreach (GTK_CONTAINER (priv->box), (GtkCallback) gtk_widget_destroy, NULL);
-       
-       if (priv->msg == NULL) {
+
+       if (priv->msg == NULL)
                return;
                return;
-       }
 
        part_to_check = modest_tny_msg_get_attachments_parent (TNY_MSG (msg));
 
        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 */
 
        /* 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));
                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;
                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);
        g_object_unref (iter);
        g_object_unref (parts);
        g_object_unref (part_to_check);
-       
 
        gtk_widget_queue_draw (GTK_WIDGET (attachments_view));
 
 
        gtk_widget_queue_draw (GTK_WIDGET (attachments_view));