[PATCH 04/11] lib: catch Xapian exceptions in n_m_get_tags

Subject: [PATCH 04/11] lib: catch Xapian exceptions in n_m_get_tags

Date: Sun, 5 Jul 2020 10:00:19 -0300

To: notmuch@notmuchmail.org

Cc: David Bremner

From: David Bremner


This allows the function to return an error value rather than
crashing.
---
 lib/message.cc         | 7 ++++++-
 test/T560-lib-error.sh | 1 -
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/message.cc b/lib/message.cc
index 6d78663b..9b7d4bc4 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -1231,7 +1231,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 94a0f470..cda3df78 100755
--- a/test/T560-lib-error.sh
+++ b/test/T560-lib-error.sh
@@ -487,7 +487,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;
-- 
2.27.0
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: