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 6E38A431FAF for ; Thu, 7 Aug 2014 11:24:17 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -2.3 X-Spam-Level: X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_MED=-2.3] 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 WSaZ3dUdM1Kw for ; Thu, 7 Aug 2014 11:24:11 -0700 (PDT) Received: from dmz-mailsec-scanner-8.mit.edu (dmz-mailsec-scanner-8.mit.edu [18.7.68.37]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 296E9431FAE for ; Thu, 7 Aug 2014 11:24:11 -0700 (PDT) X-AuditID: 12074425-f79766d000006da8-74-53e3c44a11d0 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) (using TLS with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP id FD.9A.28072.A44C3E35; Thu, 7 Aug 2014 14:24:10 -0400 (EDT) Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id s77IO8F6003230; Thu, 7 Aug 2014 14:24:09 -0400 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s77IO50K004386 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Thu, 7 Aug 2014 14:24:07 -0400 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80) (envelope-from ) id 1XFSM8-0001j4-Ag; Thu, 07 Aug 2014 14:24:04 -0400 Date: Thu, 7 Aug 2014 14:24:03 -0400 From: Austin Clements To: Tomi Ollila Subject: Re: [PATCH] notmuch-config: talloc_strdup MAILDIR and NAME environment variables Message-ID: <20140807182402.GA4741@mit.edu> References: <1407424790-12538-1-git-send-email-tomi.ollila@iki.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1407424790-12538-1-git-send-email-tomi.ollila@iki.fi> User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpileLIzCtJLcpLzFFi42IRYrdT1/U68jjY4N0lGYvrN2cyW7xZOY/V gcnj8NeFLB7PVt1iDmCK4rJJSc3JLEst0rdL4Mpo2rqapaCBs2LTfr0Gxt9sXYycHBICJhJn LpxnhLDFJC7cWw8U5+IQEpjNJHHu5zMWCGcDo8TUO9uhnFNMEjMXHWeFcJYwShz/3MEO0s8i oCIxc/0bZhCbTUBDYtv+5WBzRYDiD9rWs4LYzALSEt9+NzOB2MIC0RKrZj4Gi/MKaEvs/3WZ BcQWEnCS+PdxHxtEXFDi5MwnLBC9WhI3/r0E6uUAm7P8HweIySngLPHyRABIhSjQpiknt7FN YBSahaR5FpLmWQjNCxiZVzHKpuRW6eYmZuYUpybrFicn5uWlFula6OVmluilppRuYgQHtYvq DsYJh5QOMQpwMCrx8Ap0Pw4WYk0sK67MPcQoycGkJMrbuR8oxJeUn1KZkVicEV9UmpNafIhR goNZSYRXF6ScNyWxsiq1KB8mJc3BoiTO+9baKlhIID2xJDU7NbUgtQgmK8PBoSTBy3sYqFGw KDU9tSItM6cEIc3EwQkynAdoeAdIDW9xQWJucWY6RP4Uo6KUOO/ZQ0AJAZBERmkeXC8s6bxi FAd6RZg3B6SdB5iw4LpfAQ1mAhosqwo2uCQRISXVwOjW997aRviB/63SnYeuHllT9Sz8xYl1 zybIPV8d9Vh446cZu36evXfj+2yTNTvn3zld7r1ocluly/GSCrPPU555ZIs9rD/r8kPxjklu VUGQ4Ku7St2sz7/ujXxxaOPHIzODfofbzXU02dcdslWx9ExGsfqDTybJjQevMKpyWN54HLH5 2RkNO90aJZbijERDLeai4kQAKd3h0xUDAAA= Cc: notmuch@notmuchmail.org 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 18:24:17 -0000 LGTM. Quoth Tomi Ollila on Aug 07 at 6:19 pm: > 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);