Fixes RevNULL 1/14
[modest] / src / hildon2 / modest-msg-view-window.c
index a148f89..605f8df 100644 (file)
@@ -2426,8 +2426,10 @@ on_decode_to_stream_async_handler (TnyMimePart *mime_part,
        gchar *filepath = (gchar *) user_data;
 
        if (cancelled || err) {
-               modest_platform_information_banner (NULL, NULL, 
-                                                   _("mail_ib_file_operation_failed"));
+               if (err) {
+                       modest_platform_information_banner (NULL, NULL,
+                                                           _KR("cerm_device_memory_full"));
+               }
                goto free;
        }
 
@@ -2479,18 +2481,17 @@ modest_msg_view_window_view_attachment (ModestMsgViewWindow *window,
                        mime_part = (TnyMimePart *) tny_iterator_get_current (iter);
                        g_object_unref (iter);
                }
-               g_object_unref (selected_attachments);
+               if (selected_attachments)
+                       g_object_unref (selected_attachments);
 
                if (error)
-                       return;
+                       goto frees;
        } else {
                g_object_ref (mime_part);
        }
 
-       if (tny_mime_part_is_purged (mime_part)) {
-               g_object_unref (mime_part);
-               return;
-       }
+       if (tny_mime_part_is_purged (mime_part))
+               goto frees;
 
        if (!modest_tny_mime_part_is_msg (mime_part)) {
                gchar *filepath = NULL;
@@ -2552,7 +2553,12 @@ modest_msg_view_window_view_attachment (ModestMsgViewWindow *window,
                        gtk_widget_show_all (GTK_WIDGET (msg_win));
                }
        }
-       g_object_unref (mime_part);
+
+ frees:
+       if (attachment_uid)
+               g_free (attachment_uid);
+       if (mime_part)
+               g_object_unref (mime_part);
 }
 
 typedef struct
@@ -2630,7 +2636,7 @@ save_mime_part_to_file (SaveMimePartInfo *info)
                        g_warning ("modest: could not save attachment %s: %d (%s)\n", pair->filename, error?error->code:-1, error?error->message:"Unknown error");
 
                        if ((error->domain == TNY_ERROR_DOMAIN) && 
-                           (error->code = TNY_IO_ERROR_WRITE) &&
+                           (error->code == TNY_IO_ERROR_WRITE) &&
                            (errno == ENOSPC)) {
                                info->result = GNOME_VFS_ERROR_NO_SPACE;
                        } else {
@@ -2747,7 +2753,8 @@ save_attachments_response (GtkDialog *dialog,
 }
 
 void
-modest_msg_view_window_save_attachments (ModestMsgViewWindow *window, TnyList *mime_parts)
+modest_msg_view_window_save_attachments (ModestMsgViewWindow *window, 
+                                        TnyList *mime_parts)
 {
        ModestMsgViewWindowPrivate *priv;
        GtkWidget *save_dialog = NULL;
@@ -2762,12 +2769,17 @@ modest_msg_view_window_save_attachments (ModestMsgViewWindow *window, TnyList *m
                /* In Hildon 2.2 save and delete operate over all the attachments as there's no
                 * selection available */
                mime_parts = modest_msg_view_get_attachments (MODEST_MSG_VIEW (priv->msg_view));
-               if (!modest_maemo_utils_select_attachments (GTK_WINDOW (window), mime_parts, FALSE)) {
+               if (mime_parts && !modest_maemo_utils_select_attachments (GTK_WINDOW (window), mime_parts, FALSE)) {
                        g_object_unref (mime_parts);
                        return;
                }
-               if (mime_parts == NULL || tny_list_get_length (mime_parts) == 0)
+               if (mime_parts == NULL || tny_list_get_length (mime_parts) == 0) {
+                       if (mime_parts) {
+                               g_object_unref (mime_parts);
+                               mime_parts = NULL;
+                       }
                        return;
+               }
        } else {
                g_object_ref (mime_parts);
        }