From 31dab9b1cd66c7f285fe86021f66940f679325d4 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sat, 1 Aug 2020 09:25:50 -0300 Subject: [PATCH] lib: return NULL from n_d_get_default_indexopts on error This is a rare and probably serious programming error, so better not to silently return a default value. --- lib/indexopts.c | 2 +- lib/notmuch.h | 1 + test/T562-lib-database.sh | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/indexopts.c b/lib/indexopts.c index 1e8d180e..82a0026f 100644 --- a/lib/indexopts.c +++ b/lib/indexopts.c @@ -32,7 +32,7 @@ notmuch_database_get_default_indexopts (notmuch_database_t *db) char *decrypt_policy; notmuch_status_t err = notmuch_database_get_config (db, "index.decrypt", &decrypt_policy); if (err) - return ret; + return NULL; if (decrypt_policy) { if ((! (strcasecmp (decrypt_policy, "true"))) || diff --git a/lib/notmuch.h b/lib/notmuch.h index f9e9cc41..aaf92470 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -2320,6 +2320,7 @@ notmuch_config_list_destroy (notmuch_config_list_t *config_list); * added to the index. At the moment it is a featureless stub. * * @since libnotmuch 5.1 (notmuch 0.26) + * @retval NULL in case of error */ notmuch_indexopts_t * notmuch_database_get_default_indexopts (notmuch_database_t *db); diff --git a/test/T562-lib-database.sh b/test/T562-lib-database.sh index 32fda72e..ce62eaa8 100755 --- a/test/T562-lib-database.sh +++ b/test/T562-lib-database.sh @@ -373,7 +373,6 @@ EOF test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "get indexopts from closed database" -test_subtest_known_broken cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} { notmuch_indexopts_t *result;