From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23010 invoked by alias); 30 Jul 2018 14:14:59 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 43224 Received: (qmail 17425 invoked by uid 1010); 30 Jul 2018 14:14:58 -0000 X-Qmail-Scanner-Diagnostics: from smtpq3.tb.ukmail.iss.as9143.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(212.54.57.98):SA:0(-2.6/5.0):. Processed in 3.015865 secs); 30 Jul 2018 14:14:58 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_PASS,T_DKIMWL_WL_MED,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: p.w.stephenson@ntlworld.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | X-SourceIP: 172.25.160.136 X-Authenticated-User: p.w.stephenson@ntlworld.com Date: Mon, 30 Jul 2018 14:47:39 +0100 (BST) From: Peter Stephenson To: zsh-workers@zsh.org Message-ID: <825056567.96193.1532958460017@mail2.virginmedia.com> In-Reply-To: <8CE35533-3221-4A9D-94D9-07B4DEF54C80@kba.biglobe.ne.jp> References: <8CE35533-3221-4A9D-94D9-07B4DEF54C80@kba.biglobe.ne.jp> Subject: Re: [PATCH] fix several memory leaks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Medium X-Mailer: Open-Xchange Mailer v7.8.3-Rev48 X-Originating-IP: 213.86.214.118 X-Originating-Client: open-xchange-appsuite DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ntlworld.com; s=meg.feb2017; t=1532958460; bh=6tS8TfPBWjhAGtSMU/iunT2e4fprCDyj1RDMCTWh6Pw=; h=Date:From:To:In-Reply-To:References:Subject; b=i37xYn++jP6mZ5j2njyi/xf97bcR66ZndEu4sr5wFUeytaiPK/8UU54DmiDDTQ+qm YyR7iX51adhBPcNPfD5i23HM8rt5K9/XraoVE8OgffQx1X33bLs3JU84nYZM9fuHuz lZZKDl41l8JEjoCeD0yk5rPapZ3qtsyXGnFyWhWv3+0hfsjor/nj7oXSpJpTwKifP/ 0CxvDJP3ozremy18PPnbGwHr8OkdLQ8F+CWVoUeWoowkc/uo7qgHXkLAt92ah4A/ZZ 6wwGX+xHsedruzO9kiWnAUz512bjs2qA3ZwgDfUNuiNkXOHCPpGDc4E6gPocp7xhJy zGkmmVx2mK7zA== > On 28 July 2018 at 17:34 "Jun T." wrote: > Here is a list of memory leaks I found and their possible > fixes. Please check the patches at the end of the post, > especially those for init.c and termcap.c/terminfo.c. Thanks. > diff --git a/Src/Modules/termcap.c b/Src/Modules/termcap.c > index 60a6e138a..71257c5e9 100644 > --- a/Src/Modules/termcap.c > +++ b/Src/Modules/termcap.c > @@ -353,7 +353,8 @@ boot_(UNUSED(Module m)) > * mean the modules hasn't booted---TERM may change, > * and it should be handled dynamically---so ignore errors here. > */ > - (void)setupterm((char *)0, 1, &errret); > + if (!cur_term) /* if zsh/terminfo is not loaded */ > + (void)setupterm((char *)0, 1, &errret); > # endif > #endif > return 0; If setupterm(), over which we have no control, is really a problem we probably need a front-end with a lock to make sure it only ever gets called once. Something like a function in utils.c which as the #ifdef buried in it and simply does nothing if we don't HAVE_SETUPTERM, for example? > diff --git a/Src/init.c b/Src/init.c > index c5372665a..e9e6be9b4 100644 > --- a/Src/init.c > +++ b/Src/init.c > @@ -459,7 +459,8 @@ parseopts(char *nam, char ***argvp, char *new_opts, char **cmdp, > /* -c command */ > *cmdp = *argv; > new_opts[INTERACTIVE] &= 1; > - scriptname = scriptfilename = ztrdup("zsh"); > + if (toplevel) > + scriptname = scriptfilename = ztrdup("zsh"); > } else if (**argv == 'o') { > if (!*++*argv) > argv++; Hmm... I'm not quite sure how this case is even supposed to work when dealing with options not at top level. But simply leaving the value alone, as you've done, seems absolutely fine. pws