From e2e95caa51f8c1ea57b4fc7d3926fda1fb1aed10 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sun, 19 Feb 2012 00:56:57 +0100 Subject: [PATCH] Prevent segmentation fault in notmuch_database_close Previously opening a notmuch database in read write mode that has been locked resulted in the notmuch_database_open function executing notmuch_database_close as a cleanup function. notmuch_database_close failed to check whether the xapian database has in fact been created. Add a check whether the xapian database object has actually been created before trying to call its flush method. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de> --- lib/database.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/database.cc b/lib/database.cc index c928d02b..5efa85eb 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -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 (notmuch->xapian_db))->flush (); } catch (const Xapian::Error &error) { if (! notmuch->exception_reported) { -- 2.43.0