]> git.notmuchmail.org Git - notmuch/blobdiff - lib/open.cc
lib/create: fix memory leak, ensure *database=NULL on error
[notmuch] / lib / open.cc
index 77f01f727b6bdae860e4f7c84ce22c6af99e3a91..6fa00a843b9201d5bdf56dd15b3139e7e5adb8ec 100644 (file)
@@ -714,10 +714,16 @@ notmuch_database_create_with_config (const char *database_path,
        else
            free (message);
     }
+    if (status && notmuch) {
+       notmuch_database_destroy (notmuch);
+       notmuch = NULL;
+    }
+
     if (database)
        *database = notmuch;
-    else
-       talloc_free (notmuch);
+
+    if (notmuch)
+       notmuch->open = true;
     return status;
 }