From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 18 Feb 2012 23:56:57 +0000 (+0100) Subject: [PATCH] Prevent segmentation fault in notmuch_database_close X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=3ddd6b4ff58ecf64ee03e17f0a417af98f55ccd7;p=notmuch-archives.git [PATCH] Prevent segmentation fault in notmuch_database_close --- diff --git a/97/e5eca3b6bf77b7969d3e5613d740d127dc5276 b/97/e5eca3b6bf77b7969d3e5613d740d127dc5276 new file mode 100644 index 000000000..183b51fae --- /dev/null +++ b/97/e5eca3b6bf77b7969d3e5613d740d127dc5276 @@ -0,0 +1,92 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 2E974431FC4 + for ; Sat, 18 Feb 2012 15:57:22 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id Is-M3hrhtsUf for ; + Sat, 18 Feb 2012 15:57:20 -0800 (PST) +Received: from mail.cryptobitch.de (cryptobitch.de [88.198.7.68]) + (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 3A80B431FD2 + for ; Sat, 18 Feb 2012 15:57:18 -0800 (PST) +Received: from mail.jade-hamburg.de (unknown [85.183.11.228]) + (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.cryptobitch.de (Postfix) with ESMTPSA id 7E93A52EF7F + for ; Sun, 19 Feb 2012 00:57:16 +0100 (CET) +Received: by mail.jade-hamburg.de (Postfix, from userid 401) + id F238FDF2A2; Sun, 19 Feb 2012 00:57:15 +0100 (CET) +Received: from thinkbox.jade-hamburg.de + (dslb-092-078-042-203.pools.arcor-ip.net [92.78.42.203]) + (using TLSv1 with cipher AES256-SHA (256/256 bits)) + (No client certificate requested) (Authenticated sender: teythoon) + by mail.jade-hamburg.de (Postfix) with ESMTPSA id 5D0CEDF2A1; + Sun, 19 Feb 2012 00:57:07 +0100 (CET) +Received: from teythoon by thinkbox.jade-hamburg.de with local (Exim 4.77) + (envelope-from ) + id 1Ryu9K-0002GR-D4; Sun, 19 Feb 2012 00:57:06 +0100 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +To: notmuch@notmuchmail.org +Subject: [PATCH] Prevent segmentation fault in notmuch_database_close +Date: Sun, 19 Feb 2012 00:56:57 +0100 +Message-Id: + <1329609417-8391-2-git-send-email-4winter@informatik.uni-hamburg.de> +X-Mailer: git-send-email 1.7.9 +In-Reply-To: + <1329609417-8391-1-git-send-email-4winter@informatik.uni-hamburg.de> +References: + <1329609417-8391-1-git-send-email-4winter@informatik.uni-hamburg.de> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sat, 18 Feb 2012 23:57:22 -0000 + +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 files changed, 2 insertions(+), 1 deletions(-) + +diff --git a/lib/database.cc b/lib/database.cc +index c928d02..5efa85e 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) { +-- +1.7.9 +