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.
This commit is contained in:
David Bremner 2020-08-01 09:25:50 -03:00
parent 3f8b01a3ef
commit 31dab9b1cd
3 changed files with 2 additions and 2 deletions

View file

@ -32,7 +32,7 @@ notmuch_database_get_default_indexopts (notmuch_database_t *db)
char *decrypt_policy; char *decrypt_policy;
notmuch_status_t err = notmuch_database_get_config (db, "index.decrypt", &decrypt_policy); notmuch_status_t err = notmuch_database_get_config (db, "index.decrypt", &decrypt_policy);
if (err) if (err)
return ret; return NULL;
if (decrypt_policy) { if (decrypt_policy) {
if ((! (strcasecmp (decrypt_policy, "true"))) || if ((! (strcasecmp (decrypt_policy, "true"))) ||

View file

@ -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. * added to the index. At the moment it is a featureless stub.
* *
* @since libnotmuch 5.1 (notmuch 0.26) * @since libnotmuch 5.1 (notmuch 0.26)
* @retval NULL in case of error
*/ */
notmuch_indexopts_t * notmuch_indexopts_t *
notmuch_database_get_default_indexopts (notmuch_database_t *db); notmuch_database_get_default_indexopts (notmuch_database_t *db);

View file

@ -373,7 +373,6 @@ EOF
test_expect_equal_file EXPECTED OUTPUT test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "get indexopts from closed database" test_begin_subtest "get indexopts from closed database"
test_subtest_known_broken
cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
{ {
notmuch_indexopts_t *result; notmuch_indexopts_t *result;