bash-custom-action/bash-4.1-array.dif

43 lines
1.1 KiB
Plaintext

Andreas Schwab <schwab@linux-m68k.org> writes:
> $ declare -A a=b; unset a
> *** glibc detected *** /bin/bash: free(): invalid pointer: 0x10091644 ***
And the obvious patch:
--- builtins/declare.def
+++ builtins/declare.def 2010-04-09 17:20:51.000000000 +0000
@@ -512,7 +512,7 @@ declare_internal (list, local_var)
{
/* let bind_{array,assoc}_variable take care of this. */
if (assoc_p (var))
- bind_assoc_variable (var, name, "0", value, aflags);
+ bind_assoc_variable (var, name, savestring ("0"), value, aflags);
else
bind_array_variable (name, 0, value, aflags);
}
Roman Rakus <rrakus@redhat.com> writes:
> Repeated in the bash-4.0.38 and bash-4.1.7 by the script;
> #!/bin/bash
>
> typeset -Ai s
> y='*'
> z='['
> s[$y]=1
> s[$z]=2
> (( s[$z] = s[$z] + ${s[$y]} ))
> (( s[$y] = s[$y] + ${s[$z]} ))
> [[ ${s[$y]} = 4 ]] && echo "ok"
--- variables.c
+++ variables.c 2010-07-29 15:03:48.671425922 +0000
@@ -2398,7 +2398,7 @@ bind_int_variable (lhs, rhs)
#endif
v = bind_variable (lhs, rhs, 0);
- if (isint)
+ if (isint && v)
VSETATTR (v, att_integer);
return (v);