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 AEC0A431FC7 for ; Thu, 23 Jan 2014 04:24:21 -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 nHwtTDhIwk-H for ; Thu, 23 Jan 2014 04:24:15 -0800 (PST) Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 29B61431FB6 for ; Thu, 23 Jan 2014 04:24:15 -0800 (PST) Received: from remotemail by yantan.tethera.net with local (Exim 4.80) (envelope-from ) id 1W6JKQ-0006Wk-CX; Thu, 23 Jan 2014 08:24:14 -0400 Received: (nullmailer pid 17157 invoked by uid 1000); Thu, 23 Jan 2014 12:24:07 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH 3/3] notmuch-show: detect xapian exception in query Date: Thu, 23 Jan 2014 08:24:01 -0400 Message-Id: <1390479841-17045-4-git-send-email-david@tethera.net> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1390479841-17045-1-git-send-email-david@tethera.net> References: <1390479841-17045-1-git-send-email-david@tethera.net> 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: Thu, 23 Jan 2014 12:24:21 -0000 We want to return an error status, not 0 or (worse) segfault. --- notmuch-show.c | 6 +++++- test/T520-show.sh | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/notmuch-show.c b/notmuch-show.c index 528694b..b162738 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -1015,9 +1015,13 @@ do_show (void *ctx, notmuch_messages_t *messages; notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS; + threads = notmuch_query_search_threads (query); + if (! threads) + return NOTMUCH_STATUS_XAPIAN_EXCEPTION; + sp->begin_list (sp); - for (threads = notmuch_query_search_threads (query); + for ( ; notmuch_threads_valid (threads); notmuch_threads_move_to_next (threads)) { diff --git a/test/T520-show.sh b/test/T520-show.sh index bdd9d71..0657c99 100755 --- a/test/T520-show.sh +++ b/test/T520-show.sh @@ -6,7 +6,6 @@ test_description='"notmuch show"' add_email_corpus test_begin_subtest "exit code for show invalid query" -test_subtest_known_broken notmuch show foo.. exit_code=$? test_expect_equal 1 $exit_code -- 1.8.5.2