[PATCH 2/3] lib: Release resources if notmuch_database_open fails

Subject: [PATCH 2/3] lib: Release resources if notmuch_database_open fails

Date: Sun, 29 Jan 2012 00:50:09 -0500

To: notmuch@notmuchmail.org

Cc:

From: Austin Clements


Previously, if a Xapian exception occurred in notmuch_database_open,
we failed to clean up the allocated notmuch_database_t object.
---
 lib/database.cc |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/lib/database.cc b/lib/database.cc
index a6d15a1..94022d7 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -703,6 +703,7 @@ notmuch_database_open (const char *path,
     } catch (const Xapian::Error &error) {
 	fprintf (stderr, "A Xapian exception occurred opening database: %s\n",
 		 error.get_msg().c_str());
+	notmuch_database_close (notmuch);
 	notmuch = NULL;
     }
 
-- 
1.7.7.3


Thread: