]> git.notmuchmail.org Git - notmuch/commitdiff
lib/config: delay setting talloc destructor
authorDavid Bremner <david@tethera.net>
Sat, 8 Aug 2020 14:16:47 +0000 (11:16 -0300)
committerDavid Bremner <david@tethera.net>
Wed, 23 Dec 2020 23:48:43 +0000 (19:48 -0400)
If Xapian has thrown an exception, it is not safe to invoke the
destructor when freeing the list struct.

(cherry picked from commit 43ba5ed7eca6e9f6433b8c2c2a9d834d4101b92a)

lib/config.cc

index efab01e400708fde51470b85eee3102482f59a4e..0b760dbcc2063deeefde553fa66b5421fcf23d02 100644 (file)
@@ -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;
 }