]> git.notmuchmail.org Git - notmuch/commitdiff
lib: Release resources if notmuch_database_open fails
authorAustin Clements <amdragon@MIT.EDU>
Sun, 29 Jan 2012 05:50:09 +0000 (00:50 -0500)
committerDavid Bremner <bremner@debian.org>
Sat, 4 Feb 2012 01:15:26 +0000 (21:15 -0400)
Previously, if a Xapian exception occurred in notmuch_database_open,
we failed to clean up the allocated notmuch_database_t object.

lib/database.cc

index a6d15a13208a5535cb11e3da8275f73cc20284a8..94022d7ce3ae9c060ecf18baaca1aa95afa11781 100644 (file)
@@ -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());
     } 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;
     }
 
        notmuch = NULL;
     }