lib: check talloc success in compact
authorJani Nikula <jani@nikula.org>
Sun, 3 Nov 2013 12:24:43 +0000 (14:24 +0200)
committerDavid Bremner <david@tethera.net>
Wed, 6 Nov 2013 21:49:46 +0000 (17:49 -0400)
In line with the allocation checks all around.

lib/database.cc

index 3dfea0f4f9e27b48de199ed539f0d58e8614b684..7a8702e263c46985bb21818d3f8dd039e39799d6 100644 (file)
@@ -863,13 +863,17 @@ notmuch_database_compact (const char* path,
                          const char* backup_path,
                          notmuch_compact_status_cb_t status_cb)
 {
                          const char* backup_path,
                          notmuch_compact_status_cb_t status_cb)
 {
-    void *local = talloc_new (NULL);
+    void *local;
     char *notmuch_path, *xapian_path, *compact_xapian_path;
     char *old_xapian_path = NULL;
     notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
     notmuch_database_t *notmuch = NULL;
     struct stat statbuf;
 
     char *notmuch_path, *xapian_path, *compact_xapian_path;
     char *old_xapian_path = NULL;
     notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
     notmuch_database_t *notmuch = NULL;
     struct stat statbuf;
 
+    local = talloc_new (NULL);
+    if (! local)
+       return NOTMUCH_STATUS_OUT_OF_MEMORY;
+
     ret = notmuch_database_open(path, NOTMUCH_DATABASE_MODE_READ_WRITE, &notmuch);
     if (ret) {
        goto DONE;
     ret = notmuch_database_open(path, NOTMUCH_DATABASE_MODE_READ_WRITE, &notmuch);
     if (ret) {
        goto DONE;