unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Tomi Ollila <tomi.ollila@iki.fi>
To: notmuch@notmuchmail.org
Cc: tomi.ollila@iki.fi
Subject: [PATCH] notmuch-config: talloc_strdup MAILDIR and NAME environment variables
Date: Thu,  7 Aug 2014 18:19:50 +0300	[thread overview]
Message-ID: <1407424790-12538-1-git-send-email-tomi.ollila@iki.fi> (raw)

When defined -- the pointer is soon given to talloc_free() which
expects it to be allocated by talloc.
---
 notmuch-config.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/notmuch-config.c b/notmuch-config.c
index 88831e2..db487db 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -324,7 +324,9 @@ notmuch_config_open (void *ctx,
 
     if (notmuch_config_get_database_path (config) == NULL) {
 	char *path = getenv ("MAILDIR");
-	if (! path)
+	if (path)
+	    path = talloc_strdup (config, path);
+	else
 	    path = talloc_asprintf (config, "%s/mail",
 				    getenv ("HOME"));
 	notmuch_config_set_database_path (config, path);
@@ -333,7 +335,9 @@ notmuch_config_open (void *ctx,
 
     if (notmuch_config_get_user_name (config) == NULL) {
 	char *name = getenv ("NAME");
-	if (! name)
+	if (name)
+	    name = talloc_strdup (config, name);
+	else
 	    name = get_name_from_passwd_file (config);
 	notmuch_config_set_user_name (config, name);
 	talloc_free (name);
-- 
1.9.3

             reply	other threads:[~2014-08-07 15:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-07 15:19 Tomi Ollila [this message]
2014-08-07 18:24 ` [PATCH] notmuch-config: talloc_strdup MAILDIR and NAME environment variables Austin Clements
2014-08-08  0:14 ` 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=1407424790-12538-1-git-send-email-tomi.ollila@iki.fi \
    --to=tomi.ollila@iki.fi \
    --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).