zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: Anssi Palin <Anssi.Palin@edu.omnia.fi>,
	"zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: [[ -v a[key] ]] syntax memory leak & undefined associative array keys detected as set
Date: Thu, 9 Aug 2018 09:30:59 +0100	[thread overview]
Message-ID: <20180809083101eucas1p2d266a0dbbf829c318250c9ed3d049331~JKh8choDx2821128211eucas1p2b@eucas1p2.samsung.com> (raw)
In-Reply-To: <HE1PR05MB18337958FCC269492C3E1C27D7260@HE1PR05MB1833.eurprd05.prod.outlook.com>

On Wed, 8 Aug 2018 21:31:05 +0000
Anssi Palin <Anssi.Palin@edu.omnia.fi> wrote:
> My original message in this thread about problems introduced around
> Zsh 5.5.1 with the ${+a[$key]} syntax went somewhat unnoticed. Has
> the issue been investigated since? I feel the problem is somewhat
> urgent as in the meantime I've modified some of my scripts to use a
> workaround with dummy keys to get them to execute similarly as before.

It looks like the simple change does the right thing, though this isn't
code I tend to look at.

By the way, although this is certainly a real bug, you'll tend to find
you hit fewer if you don't mix native zsh features (such as ${+...})
with features designed to support [k]sh --- the overlap between the two
worlds is very complicated and probably the most poorly tested part of
the system.

diff --git a/Src/params.c b/Src/params.c
index f130934..a1c299f 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -1427,7 +1427,7 @@ getarg(char **str, int *inv, Value v, int a2, zlong *w,
 	    HashTable ht = v->pm->gsu.h->getfn(v->pm);
 	    if (!ht) {
 		if (flags & SCANPM_CHECKING)
-		    return isset(KSHARRAYS) ? 1 : 0;
+		    return 0;
 		ht = newparamtable(17, v->pm->node.nam);
 		v->pm->gsu.h->setfn(v->pm, ht);
 	    }
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index 3b187f4..e327a78 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -2422,3 +2422,11 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888
 >: #
 >: ` backtick
 >: word
+
+  (
+    setopt KSH_ARRAYS
+    typeset -A ksh_assoc
+    print ${+assoc[unset]}
+  )
+0:Use of parameter subst + to test element of hash with KSH_ARRAYS.
+>0


  parent reply	other threads:[~2018-08-09  8:31 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
2018-08-08 21:31 ` Anssi Palin
2018-08-08 22:44   ` Joey Pabalinas
2018-08-09  8:30   ` Peter Stephenson [this message]
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='20180809083101eucas1p2d266a0dbbf829c318250c9ed3d049331~JKh8choDx2821128211eucas1p2b@eucas1p2.samsung.com' \
    --to=p.stephenson@samsung.com \
    --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).