Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [[ -v a[key] ]] syntax memory leak & undefined associative array keys detected as set
On Wed, 8 Aug 2018 21:31:05 +0000
Anssi Palin <Anssi.Palin@xxxxxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author