diff options
| author | David Bremner <david@tethera.net> | 2020-07-05 10:00:19 -0300 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2020-07-14 07:12:52 -0300 |
| commit | 00f1abfdf45025f176e079b794f4df0ee4afa9cb (patch) | |
| tree | 90496eedb73508230600e51593dd510562049de5 | |
| parent | d284dc00dafb144065bc50242e15e84d4579e3fd (diff) | |
lib: catch Xapian exceptions in n_m_get_tags
This allows the function to return an error value rather than
crashing.
| -rw-r--r-- | lib/message.cc | 7 | ||||
| -rwxr-xr-x | test/T560-lib-error.sh | 1 |
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/message.cc b/lib/message.cc index f4306e2c..364cdc9d 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -1206,7 +1206,12 @@ notmuch_message_get_tags (notmuch_message_t *message) { 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); /* _notmuch_tags_create steals the reference to the tag_list, but diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh index 05d41615..fff215e4 100755 --- a/test/T560-lib-error.sh +++ b/test/T560-lib-error.sh @@ -471,7 +471,6 @@ EOF test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "Handle getting tags from closed database" -test_subtest_known_broken cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} { notmuch_tags_t *result; |
