notmuch-show: detect NULL pointer returned from notmuch_query_search_threads

We want to return an error status, not 0 or (worse) segfault.
This commit is contained in:
David Bremner 2014-01-23 08:24:01 -04:00
parent 29f1252126
commit ecbb29e8ce
2 changed files with 5 additions and 2 deletions

View file

@ -1015,9 +1015,13 @@ do_show (void *ctx,
notmuch_messages_t *messages; notmuch_messages_t *messages;
notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS; notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS;
threads = notmuch_query_search_threads (query);
if (! threads)
return 1;
sp->begin_list (sp); sp->begin_list (sp);
for (threads = notmuch_query_search_threads (query); for ( ;
notmuch_threads_valid (threads); notmuch_threads_valid (threads);
notmuch_threads_move_to_next (threads)) notmuch_threads_move_to_next (threads))
{ {

View file

@ -6,7 +6,6 @@ test_description='"notmuch show"'
add_email_corpus add_email_corpus
test_begin_subtest "exit code for show invalid query" test_begin_subtest "exit code for show invalid query"
test_subtest_known_broken
notmuch show foo.. notmuch show foo..
exit_code=$? exit_code=$?
test_expect_equal 1 $exit_code test_expect_equal 1 $exit_code