]> git.notmuchmail.org Git - notmuch/commitdiff
add_message: Fix memory leak of thread_ids GPtrArray.
authorCarl Worth <cworth@cworth.org>
Tue, 20 Oct 2009 20:05:45 +0000 (13:05 -0700)
committerCarl Worth <cworth@cworth.org>
Tue, 20 Oct 2009 20:05:45 +0000 (13:05 -0700)
We were properly feeing this memory when the thread-ids list was not
empty, but leaking it when it was.

Thanks, of course, to valgrind along with the G_SLICE=always-malloc
environment variable which makes leak checking with glib almost
bearable.

database.cc

index abae58205f897779871113199c703798d7cbfb8a..59e837360018a72aeff4195f21b0b3b724e75334 100644 (file)
@@ -577,7 +577,6 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
 
                free (id);
            }
-           g_ptr_array_free (thread_ids, TRUE);
            doc.add_value (NOTMUCH_VALUE_THREAD, thread_id->str);
            g_string_free (thread_id, TRUE);
        } else if (message_id) {
@@ -589,6 +588,8 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
            doc.add_value (NOTMUCH_VALUE_THREAD, thread_id.str);
        }
 
+       g_ptr_array_free (thread_ids, TRUE);
+
        free (message_id);
 
        date = notmuch_message_get_header (message, "date");