]> git.notmuchmail.org Git - notmuch/blobdiff - lib/database.cc
Prevent segmentation fault in notmuch_database_close
[notmuch] / lib / database.cc
index c928d02bb147b039dae529be337dda8055a0b757..5efa85eb162ab47085f4105ebd5b0a0a86f84ddd 100644 (file)
@@ -716,7 +716,8 @@ void
 notmuch_database_close (notmuch_database_t *notmuch)
 {
     try {
-       if (notmuch->mode == NOTMUCH_DATABASE_MODE_READ_WRITE)
+       if (notmuch->xapian_db != NULL &&
+           notmuch->mode == NOTMUCH_DATABASE_MODE_READ_WRITE)
            (static_cast <Xapian::WritableDatabase *> (notmuch->xapian_db))->flush ();
     } catch (const Xapian::Error &error) {
        if (! notmuch->exception_reported) {