From: Tomi Ollila Date: Thu, 7 Aug 2014 15:19:50 +0000 (+0300) Subject: [PATCH] notmuch-config: talloc_strdup MAILDIR and NAME environment variables X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c3beddea4ba453c9ebb81b64f62c884f6801945a;p=notmuch-archives.git [PATCH] notmuch-config: talloc_strdup MAILDIR and NAME environment variables --- diff --git a/b9/01f89f79350adafe9d45fcad8ee4aa2befa86c b/b9/01f89f79350adafe9d45fcad8ee4aa2befa86c new file mode 100644 index 000000000..a7b9428c1 --- /dev/null +++ b/b9/01f89f79350adafe9d45fcad8ee4aa2befa86c @@ -0,0 +1,78 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id C9C9E431FAE + for ; Thu, 7 Aug 2014 08:20:22 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 29k-NnquOo3X for ; + Thu, 7 Aug 2014 08:20:18 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id D8CE9431FC2 + for ; Thu, 7 Aug 2014 08:20:05 -0700 (PDT) +Received: by guru.guru-group.fi (Postfix, from userid 501) + id D52BE1000E0; Thu, 7 Aug 2014 18:19:52 +0300 (EEST) +From: Tomi Ollila +To: notmuch@notmuchmail.org +Subject: [PATCH] notmuch-config: talloc_strdup MAILDIR and NAME environment + variables +Date: Thu, 7 Aug 2014 18:19:50 +0300 +Message-Id: <1407424790-12538-1-git-send-email-tomi.ollila@iki.fi> +X-Mailer: git-send-email 2.0.0 +Cc: tomi.ollila@iki.fi +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Thu, 07 Aug 2014 15:20:22 -0000 + +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 +