[PATCH 3/3] notmuch-show: detect xapian exception in query
authorDavid Bremner <david@tethera.net>
Thu, 23 Jan 2014 12:24:01 +0000 (08:24 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:59:13 +0000 (09:59 -0800)
d6/071d7721590d657e94cafa654a3a56d91b737f [new file with mode: 0644]

diff --git a/d6/071d7721590d657e94cafa654a3a56d91b737f b/d6/071d7721590d657e94cafa654a3a56d91b737f
new file mode 100644 (file)
index 0000000..0bcd7b2
--- /dev/null
@@ -0,0 +1,89 @@
+Return-Path: <bremner@tethera.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id AEC0A431FC7\r
+       for <notmuch@notmuchmail.org>; Thu, 23 Jan 2014 04:24:21 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id nHwtTDhIwk-H for <notmuch@notmuchmail.org>;\r
+       Thu, 23 Jan 2014 04:24:15 -0800 (PST)\r
+Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155])\r
+       (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 29B61431FB6\r
+       for <notmuch@notmuchmail.org>; Thu, 23 Jan 2014 04:24:15 -0800 (PST)\r
+Received: from remotemail by yantan.tethera.net with local (Exim 4.80)\r
+       (envelope-from <bremner@tethera.net>)\r
+       id 1W6JKQ-0006Wk-CX; Thu, 23 Jan 2014 08:24:14 -0400\r
+Received: (nullmailer pid 17157 invoked by uid 1000); Thu, 23 Jan 2014\r
+       12:24:07 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 3/3] notmuch-show: detect xapian exception in query\r
+Date: Thu, 23 Jan 2014 08:24:01 -0400\r
+Message-Id: <1390479841-17045-4-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 1.8.5.2\r
+In-Reply-To: <1390479841-17045-1-git-send-email-david@tethera.net>\r
+References: <m2r47zrkkc.fsf@guru.guru-group.fi>\r
+       <1390479841-17045-1-git-send-email-david@tethera.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 23 Jan 2014 12:24:21 -0000\r
+\r
+We want to return an error status, not 0 or (worse) segfault.\r
+---\r
+ notmuch-show.c    | 6 +++++-\r
+ test/T520-show.sh | 1 -\r
+ 2 files changed, 5 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/notmuch-show.c b/notmuch-show.c\r
+index 528694b..b162738 100644\r
+--- a/notmuch-show.c\r
++++ b/notmuch-show.c\r
+@@ -1015,9 +1015,13 @@ do_show (void *ctx,\r
+     notmuch_messages_t *messages;\r
+     notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS;\r
\r
++    threads = notmuch_query_search_threads (query);\r
++    if (! threads)\r
++      return NOTMUCH_STATUS_XAPIAN_EXCEPTION;\r
++\r
+     sp->begin_list (sp);\r
\r
+-    for (threads = notmuch_query_search_threads (query);\r
++    for ( ;\r
+        notmuch_threads_valid (threads);\r
+        notmuch_threads_move_to_next (threads))\r
+     {\r
+diff --git a/test/T520-show.sh b/test/T520-show.sh\r
+index bdd9d71..0657c99 100755\r
+--- a/test/T520-show.sh\r
++++ b/test/T520-show.sh\r
+@@ -6,7 +6,6 @@ test_description='"notmuch show"'\r
+ add_email_corpus\r
\r
+ test_begin_subtest "exit code for show invalid query"\r
+-test_subtest_known_broken\r
+ notmuch show foo..\r
+ exit_code=$?\r
+ test_expect_equal 1 $exit_code\r
+-- \r
+1.8.5.2\r
+\r