[PATCH 4/6] lib/config: delay setting talloc destructor

2020-12-20 Thread David Bremner
If Xapian has thrown an exception, it is not safe to invoke the
destructor when freeing the list struct.
---
 lib/config.cc | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/config.cc b/lib/config.cc
index efab01e4..0b760dbc 100644
--- a/lib/config.cc
+++ b/lib/config.cc
@@ -133,8 +133,15 @@ notmuch_database_get_config_list (notmuch_database_t 
*notmuch,
 *out = list;
 
   DONE:
-if (status && list)
-   talloc_free (list);
+if (status) {
+   if (list) {
+   talloc_free (list);
+   if (status != NOTMUCH_STATUS_XAPIAN_EXCEPTION)
+   _notmuch_config_list_destroy (list);
+   }
+}  else {
+   talloc_set_destructor (list, _notmuch_config_list_destroy);
+}
 
 return status;
 }
-- 
2.29.2
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 4/6] lib/config: delay setting talloc destructor

2020-08-12 Thread David Bremner
If Xapian has thrown an exception, it is not safe to invoke the
destuctor when freeing the list struct.
---
 lib/config.cc | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/lib/config.cc b/lib/config.cc
index dae0ff0e..d0497052 100644
--- a/lib/config.cc
+++ b/lib/config.cc
@@ -113,7 +113,6 @@ notmuch_database_get_config_list (notmuch_database_t 
*notmuch,
goto DONE;
 }
 
-talloc_set_destructor (list, _notmuch_config_list_destroy);
 list->notmuch = notmuch;
 list->current_key = NULL;
 list->current_val = NULL;
@@ -133,8 +132,15 @@ notmuch_database_get_config_list (notmuch_database_t 
*notmuch,
 *out = list;
 
   DONE:
-if (status && list)
-   talloc_free (list);
+if (status) {
+   if (list) {
+   talloc_free (list);
+   if (status != NOTMUCH_STATUS_XAPIAN_EXCEPTION)
+   _notmuch_config_list_destroy (list);
+   }
+}  else {
+   talloc_set_destructor (list, _notmuch_config_list_destroy);
+}
 
 return status;
 }
-- 
2.28.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org