Fix a memory leak from MH-format camel provider
authorMilan Crha <mcrha@redhat.com>
Thu, 13 Sep 2012 08:37:54 +0000 (10:37 +0200)
committerMilan Crha <mcrha@redhat.com>
Thu, 13 Sep 2012 08:37:54 +0000 (10:37 +0200)
camel/providers/local/camel-mh-summary.c

index 50e1ace..dd22b17 100644 (file)
@@ -254,7 +254,13 @@ mh_summary_check (CamelLocalSummary *cls,
                        if (info == NULL || (cls->index && (!camel_index_has_name (cls->index, d->d_name)))) {
                                /* need to add this file to the summary */
                                if (info != NULL) {
-                                       g_hash_table_remove (left, camel_message_info_uid (info));
+                                       CamelMessageInfo *old = g_hash_table_lookup (left, camel_message_info_uid (info));
+
+                                       if (old) {
+                                               g_hash_table_remove (left, camel_message_info_uid (info));
+                                               camel_message_info_free (old);
+                                       }
+
                                        camel_folder_summary_remove ((CamelFolderSummary *) cls, info);
                                        camel_message_info_free (info);
                                }
@@ -264,8 +270,8 @@ mh_summary_check (CamelLocalSummary *cls,
                                CamelMessageInfo *old = g_hash_table_lookup (left, uid);
 
                                if (old) {
-                                       camel_message_info_free (old);
                                        g_hash_table_remove (left, uid);
+                                       camel_message_info_free (old);
                                }
                                camel_message_info_free (info);
                        }
@@ -331,6 +337,8 @@ mh_summary_sync (CamelLocalSummary *cls,
                camel_message_info_free (info);
        }
 
+       camel_folder_summary_free_array (known_uids);
+
        /* Chain up to parent's sync() method. */
        local_summary_class = CAMEL_LOCAL_SUMMARY_CLASS (camel_mh_summary_parent_class);
        return local_summary_class->sync (cls, expunge, changes, cancellable, error);