unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Jani Nikula <jani@nikula.org>
To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org
Subject: Re: [PATCH 2/3] lib: make notmuch_threads_valid return FALSE when passed NULL
Date: Fri, 24 Jan 2014 23:06:28 +0200	[thread overview]
Message-ID: <87wqhpf5t7.fsf@nikula.org> (raw)
In-Reply-To: <1390479841-17045-3-git-send-email-david@tethera.net>

On Thu, 23 Jan 2014, David Bremner <david@tethera.net> wrote:
> Without this patch, the example code in the header docs crashes for certain
> invalid queries (see id:871u00oimv.fsf@approx.mit.edu)
> ---
>  lib/notmuch.h | 2 ++
>  lib/query.cc  | 3 +++
>  2 files changed, 5 insertions(+)
>
> diff --git a/lib/notmuch.h b/lib/notmuch.h
> index 02604c5..68896ae 100644
> --- a/lib/notmuch.h
> +++ b/lib/notmuch.h
> @@ -802,6 +802,8 @@ notmuch_query_destroy (notmuch_query_t *query);
>   * valid object. Whereas when this function returns FALSE,
>   * notmuch_threads_get will return NULL.
>   *
> + * If passed a NULL pointer, this function returns FALSE
> + *
>   * See the documentation of notmuch_query_search_threads for example
>   * code showing how to iterate over a notmuch_threads_t object.
>   */
> diff --git a/lib/query.cc b/lib/query.cc
> index ec60e2e..60ff8bd 100644
> --- a/lib/query.cc
> +++ b/lib/query.cc
> @@ -462,6 +462,9 @@ notmuch_threads_valid (notmuch_threads_t *threads)
>  {
>      unsigned int doc_id;
>  
> +    if (! threads)
> +	return FALSE;
> +

LGTM, and this is in line with notmuch_messages_valid().

BR,
Jani.

>      while (threads->doc_id_pos < threads->doc_ids->len) {
>  	doc_id = g_array_index (threads->doc_ids, unsigned int,
>  				threads->doc_id_pos);
> -- 
> 1.8.5.2
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

  reply	other threads:[~2014-01-24 21:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-22  2:27 segfault if notmuch-show query has spurious .. (w/ v0.17) Sanjoy Mahajan
2014-01-22 12:40 ` David Bremner
2014-01-22 16:42   ` [PATCH] lib: make notmuch_threads_valid return FALSE when passed NULL David Bremner
2014-01-22 17:30     ` Tomi Ollila
2014-01-23 12:23       ` Round 2: fix for notmuch show segfault David Bremner
2014-01-23 12:23         ` [PATCH 1/3] test: add known broken test exit code of notmuch show David Bremner
2014-01-23 12:24         ` [PATCH 2/3] lib: make notmuch_threads_valid return FALSE when passed NULL David Bremner
2014-01-24 21:06           ` Jani Nikula [this message]
2014-01-23 12:24         ` [PATCH 3/3] notmuch-show: detect xapian exception in query David Bremner
2014-01-24 21:12           ` Jani Nikula
2014-01-25  0:41             ` David Bremner
2014-01-23 17:50         ` Round 2: fix for notmuch show segfault Mark Walters
2014-01-24 18:43           ` Tomi Ollila
2014-01-25  1:01 ` segfault if notmuch-show query has spurious .. (w/ v0.17) David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wqhpf5t7.fsf@nikula.org \
    --to=jani@nikula.org \
    --cc=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).