--- /dev/null
+Return-Path: <tomi.ollila@iki.fi>\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 1BF6D431FBD\r
+ for <notmuch@notmuchmail.org>; Wed, 22 Jan 2014 09:30:27 -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 okzLUm7lM6c7 for <notmuch@notmuchmail.org>;\r
+ Wed, 22 Jan 2014 09:30:21 -0800 (PST)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by olra.theworths.org (Postfix) with ESMTP id 7C37F431FAF\r
+ for <notmuch@notmuchmail.org>; Wed, 22 Jan 2014 09:30:21 -0800 (PST)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+ by guru.guru-group.fi (Postfix) with ESMTP id 2EF511000B3;\r
+ Wed, 22 Jan 2014 19:30:12 +0200 (EET)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] lib: make notmuch_threads_valid return FALSE when passed\r
+ NULL\r
+In-Reply-To: <1390408979-28606-1-git-send-email-david@tethera.net>\r
+References: <8738kgrxyf.fsf@zancas.localnet>\r
+ <1390408979-28606-1-git-send-email-david@tethera.net>\r
+User-Agent: Notmuch/0.17+41~g8e7fabf (http://notmuchmail.org) Emacs/24.3.1\r
+ (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+ $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+ !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Wed, 22 Jan 2014 19:30:11 +0200\r
+Message-ID: <m2r47zrkkc.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\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: Wed, 22 Jan 2014 17:30:27 -0000\r
+\r
+On Wed, Jan 22 2014, David Bremner <david@tethera.net> wrote:\r
+\r
+> Without this patch, the example code in the header docs crashes for certain\r
+> invalid queries (see id:871u00oimv.fsf@approx.mit.edu)\r
+> ---\r
+\r
+Looks good and seems to work:\r
+\r
+$ make\r
+...\r
+$ notmuch show foo..\r
+A Xapian exception occurred performing query: Unknown range operation\r
+Query string was: foo..\r
+zsh: segmentation fault notmuch show foo..\r
+$ ./notmuch show foo..\r
+A Xapian exception occurred performing query: Unknown range operation\r
+Query string was: foo..\r
+\r
+(i.e. no "segmentation fault" in the latter)\r
+\r
+Tomi\r
+\r
+\r
+> lib/notmuch.h | 2 ++\r
+> lib/query.cc | 3 +++\r
+> 2 files changed, 5 insertions(+)\r
+>\r
+> diff --git a/lib/notmuch.h b/lib/notmuch.h\r
+> index 02604c5..68896ae 100644\r
+> --- a/lib/notmuch.h\r
+> +++ b/lib/notmuch.h\r
+> @@ -802,6 +802,8 @@ notmuch_query_destroy (notmuch_query_t *query);\r
+> * valid object. Whereas when this function returns FALSE,\r
+> * notmuch_threads_get will return NULL.\r
+> *\r
+> + * If passed a NULL pointer, this function returns FALSE\r
+> + *\r
+> * See the documentation of notmuch_query_search_threads for example\r
+> * code showing how to iterate over a notmuch_threads_t object.\r
+> */\r
+> diff --git a/lib/query.cc b/lib/query.cc\r
+> index ec60e2e..60ff8bd 100644\r
+> --- a/lib/query.cc\r
+> +++ b/lib/query.cc\r
+> @@ -462,6 +462,9 @@ notmuch_threads_valid (notmuch_threads_t *threads)\r
+> {\r
+> unsigned int doc_id;\r
+> \r
+> + if (! threads)\r
+\r
+This format seems to be consistent with surrounding code (vs. threads == NULL)\r
+\r
+> + return FALSE;\r
+> +\r
+> while (threads->doc_id_pos < threads->doc_ids->len) {\r
+> doc_id = g_array_index (threads->doc_ids, unsigned int,\r
+> threads->doc_id_pos);\r
+> -- \r
+> 1.8.5.2\r