diff options
author | Tomi Ollila <tomi.ollila@iki.fi> | 2014-08-07 18:19:50 +0300 |
---|---|---|
committer | David Bremner <david@tethera.net> | 2014-08-07 21:12:27 -0300 |
commit | 748798511d7cb704ee7f9ce98cfbf87ebc41ab0f (patch) | |
tree | 37265e3fb3c86417aeb7b288f08544b580352ff1 /notmuch-config.c | |
parent | 9f0f30f7dea1b8fd888d774175ed96d802118b11 (diff) |
notmuch-config: talloc_strdup MAILDIR and NAME environment variables
When defined -- the pointer is soon given to talloc_free() which
expects it to be allocated by talloc.
Diffstat (limited to 'notmuch-config.c')
-rw-r--r-- | notmuch-config.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/notmuch-config.c b/notmuch-config.c index 88831e27..db487dbe 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); |