Fixes RevNULL 2/14
[modest] / src / modest-tny-msg.c
index a249f7c..b64155a 100644 (file)
@@ -33,6 +33,7 @@
 #include <tny-simple-list.h>
 #include <tny-folder.h>
 #include <modest-runtime.h>
+#include <modest-defs.h>
 #include "modest-formatter.h"
 #include <tny-camel-mem-stream.h>
 #include <tny-camel-mime-part.h>
@@ -367,9 +368,9 @@ add_images (TnyMsg *msg, GList *images_list, GError **err)
                        if (part && !g_strcasecmp (tny_mime_part_get_content_type (part), "multipart/related")) {
                                related_part = part;
                                break;
-                       } else {
-                               g_object_unref (part);
                        }
+                       if (part)
+                               g_object_unref (part);
                        tny_iterator_next (iter);
                }
                g_object_unref (iter);
@@ -488,6 +489,7 @@ modest_tny_msg_find_body_part_from_mime_part (TnyMimePart *msg, gboolean want_ht
 
                        if (!part) {
                                g_warning ("%s: not a valid mime part", __FUNCTION__);
+                               tny_iterator_next (iter);
                                continue;
                        }
 
@@ -866,8 +868,7 @@ modest_tny_msg_create_reply_msg (TnyMsg *msg,
                g_list_foreach (attachments_list, (GFunc) g_object_unref, NULL);
                g_list_free (attachments_list);
        }
-       if (parts)
-               g_object_unref (G_OBJECT (parts));
+       g_object_unref (parts);
 
        /* Fill the header */
        if (header)