zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@zsh.org
Subject: Re: [PATCH] fix several memory leaks
Date: Mon, 30 Jul 2018 14:47:39 +0100 (BST)	[thread overview]
Message-ID: <825056567.96193.1532958460017@mail2.virginmedia.com> (raw)
In-Reply-To: <8CE35533-3221-4A9D-94D9-07B4DEF54C80@kba.biglobe.ne.jp>

> On 28 July 2018 at 17:34 "Jun T." <takimoto-j@kba.biglobe.ne.jp> 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


  parent reply	other threads:[~2018-07-30 14:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-28 16:34 Jun T.
2018-07-28 17:20 ` Jun T.
2018-07-28 18:57   ` Bart Schaefer
2018-08-01 11:14     ` Jun T
2018-07-30 13:47 ` Peter Stephenson [this message]
2018-07-31 14:30   ` Jun T.
2018-07-31 14:41     ` Peter Stephenson

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=825056567.96193.1532958460017@mail2.virginmedia.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@zsh.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://git.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).