[PATCH 3/3] notmuch-show: detect xapian exception in query

Jani Nikula jani at nikula.org
Fri Jan 24 13:12:46 PST 2014


On Thu, 23 Jan 2014, David Bremner <david at tethera.net> wrote:
> 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;

This should just return 1 or something. See how the function eventually
returns res != NOTMUCH_STATUS_SUCCESS instead of notmuch_status_t. And
threads == NULL is not guaranteed to mean an exception occurred anyway.

Otherwise the patch LGTM, and is in line with the error handling in
notmuch search, which does not segfault on similar queries.

BR,
Jani.


> +
>      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
>
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


More information about the notmuch mailing list