]> git.notmuchmail.org Git - notmuch/blobdiff - database.cc
add_message: Fix memory leak of thread_ids GPtrArray.
[notmuch] / database.cc
index 528ae1154b48d9b4428c214355700e96f5123564..59e837360018a72aeff4195f21b0b3b724e75334 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <xapian.h>
 
-#include <glib.h> /* g_strdup_printf, g_free, GHashTable */
+#include <glib.h> /* g_strdup_printf, g_free, GPtrArray, GHashTable */
 
 using namespace std;
 
@@ -450,8 +450,8 @@ notmuch_database_open (const char *path)
 
     err = stat (notmuch_path, &st);
     if (err) {
-       fprintf (stderr, "Error: Cannot stat %s: %s\n",
-                notmuch_path, strerror (err));
+       fprintf (stderr, "Error opening database at %s: %s\n",
+                notmuch_path, strerror (errno));
        goto DONE;
     }
 
@@ -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");