From: David Bremner Date: Thu, 23 Jan 2014 12:24:01 +0000 (-0400) Subject: notmuch-show: detect NULL pointer returned from notmuch_query_search_threads X-Git-Tag: 0.18_rc0~181 X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;ds=sidebyside;h=ecbb29e8cea404faab2ef55b06431942ee329941;p=notmuch notmuch-show: detect NULL pointer returned from notmuch_query_search_threads We want to return an error status, not 0 or (worse) segfault. --- diff --git a/notmuch-show.c b/notmuch-show.c index 528694be..d416fbd5 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 1; + 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 bdd9d716..0657c993 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