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



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



Messages sorted by: Reverse Date, Date, Thread, Author