zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: Anssi Palin <Anssi.Palin@edu.omnia.fi>
Cc: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: [[ -v a[key] ]] syntax memory leak & undefined associative array keys detected as set
Date: Sat, 19 May 2018 10:49:06 +0200	[thread overview]
Message-ID: <32310.1526719746@thecus> (raw)
In-Reply-To: <HE1PR05MB183333C4D7750364A8B01D0CD7900@HE1PR05MB1833.eurprd05.prod.outlook.com>

Anssi Palin wrote:
>
> In workers/41719 I wrote about a memory leak with the (( ${+a[key]} )) syntax. 
> While the issue has since been patched I've now noticed that the alternative 
> [[ -v a[key] ]] syntax still suffers from the same problem in 5.5.1.

After looking at the patch for the first issue, I tried the following
and it does fix the issue for [[ -v a[key] ]].

+++ b/Src/params.c
@@ -691,7 +691,7 @@ issetvar(char *name)
-    if (!(v = getvalue(&vbuf, &name, 1)) || *name)
+    if (!(v = fetchvalue(&vbuf, &name, 1, SCANPM_CHECKING)) || *name)

However, the problem seems to even occur for something like
  : ${a[$i]}

We need to differentiate anything that does assignment and should create
the parameter if it isn't already there.

Oliver


  reply	other threads:[~2018-05-19  8:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-18 21:59 Anssi Palin
2018-05-19  8:49 ` Oliver Kiddle [this message]
2018-08-08 21:31 ` Anssi Palin
2018-08-08 22:44   ` Joey Pabalinas
2018-08-09  8:30   ` Peter Stephenson
2018-08-09  9:46 ` Sebastian Gniazdowski

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=32310.1526719746@thecus \
    --to=okiddle@yahoo.co.uk \
    --cc=Anssi.Palin@edu.omnia.fi \
    --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).