lib: catch Xapian exceptions in n_m_get_tags

This allows the function to return an error value rather than
crashing.
This commit is contained in:
David Bremner 2020-07-05 10:00:19 -03:00
parent d284dc00da
commit 00f1abfdf4
2 changed files with 6 additions and 2 deletions

View file

@ -1206,7 +1206,12 @@ notmuch_message_get_tags (notmuch_message_t *message)
{ {
notmuch_tags_t *tags; notmuch_tags_t *tags;
_notmuch_message_ensure_metadata (message, message->tag_list); try {
_notmuch_message_ensure_metadata (message, message->tag_list);
} catch (Xapian::Error &error) {
LOG_XAPIAN_EXCEPTION (message, error);
return NULL;
}
tags = _notmuch_tags_create (message, message->tag_list); tags = _notmuch_tags_create (message, message->tag_list);
/* _notmuch_tags_create steals the reference to the tag_list, but /* _notmuch_tags_create steals the reference to the tag_list, but

View file

@ -471,7 +471,6 @@ EOF
test_expect_equal_file EXPECTED OUTPUT test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "Handle getting tags from closed database" test_begin_subtest "Handle getting tags from closed database"
test_subtest_known_broken
cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
{ {
notmuch_tags_t *result; notmuch_tags_t *result;