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: Wed, 12 Aug 2020 19:49:29 -0300	[thread overview]
Message-ID: <20200812224931.3611801-5-david@tethera.net> (raw)
In-Reply-To: <20200812224931.3611801-1-david@tethera.net>

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

  parent reply	other threads:[~2020-08-12 22:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-12 22:49 preliminaries for merged config David Bremner
2020-08-12 22:49 ` [PATCH 1/6] test: use keys with group 'test' in T590-libconfig David Bremner
2020-08-12 22:49 ` [PATCH 2/6] lib: factor out feature name related code David Bremner
2020-08-12 22:49 ` [PATCH 3/6] lib: factor out prefix related code to its own file David Bremner
2020-08-12 22:49 ` David Bremner [this message]
2020-08-12 22:49 ` [PATCH 5/6] test: add regression test for searching with alternate config David Bremner
2020-08-12 22:49 ` [PATCH 6/6] lib: factor out notmuch_database_open* related code to own file David Bremner
  -- strict thread matches above, loose matches on Subject: below --
2020-12-20 12:10 v2 preliminaries for merged config David Bremner
2020-12-20 12:10 ` [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=20200812224931.3611801-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).