unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Cc: David Bremner <david@tethera.net>
Subject: [PATCH 4/6] lib/config: delay setting talloc destructor
Date: Sun, 20 Dec 2020 08:10:22 -0400	[thread overview]
Message-ID: <20201220121024.1122362-5-david@tethera.net> (raw)
In-Reply-To: <20201220121024.1122362-1-david@tethera.net>

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

  parent reply	other threads:[~2020-12-20 12:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-20 12:10 v2 preliminaries for merged config David Bremner
2020-12-20 12:10 ` [PATCH 1/6] test: use keys with group 'test' in T590-libconfig David Bremner
2020-12-20 12:10 ` [PATCH 2/6] lib: factor out feature name related code David Bremner
2020-12-20 12:10 ` [PATCH 3/6] lib: factor out prefix related code to its own file David Bremner
2020-12-20 15:36   ` Tomi Ollila
2020-12-20 20:03     ` David Bremner
2020-12-20 12:10 ` David Bremner [this message]
2020-12-20 12:10 ` [PATCH 5/6] test: add regression test for searching with alternate config David Bremner
2020-12-20 12:10 ` [PATCH 6/6] lib: factor out notmuch_database_open* related code to own file David Bremner
2020-12-23 23:50 ` v2 preliminaries for merged config David Bremner
  -- strict thread matches above, loose matches on Subject: below --
2020-08-12 22:49 David Bremner
2020-08-12 22:49 ` [PATCH 4/6] lib/config: delay setting talloc destructor David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201220121024.1122362-5-david@tethera.net \
    --to=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).