On 4/27/16 2:45 AM, Grisha Levit wrote:
> Any of the following will crash bash:
>
> declare -n ref=a[*]; ref=
> declare -n ref=a[@]; ref=
> declare -n ref=a[-1]; a=(); ref=
>
> declare -A A; declare -n ref='A[$unset]'; ref=
>
> They all produce "bad array subscript" errors so could be caught.
T
Hi Grisha,
confirmed.
I think this one fixes it:
diff --git a/variables.c b/variables.c
index 69ed170..9eeda46 100644
--- a/variables.c
+++ b/variables.c
@@ -2636,9 +2636,14 @@ bind_variable_internal (name, value, table, hflags,
aflags)
#if defined (ARRAY_VARS)
/* declare -n foo=x[2] *
Any of the following will crash bash:
declare -n ref=a[*]; ref=
declare -n ref=a[@]; ref=
declare -n ref=a[-1]; a=(); ref=
declare -A A; declare -n ref='A[$unset]'; ref=
They all produce "bad array subscript" errors so could be caught.
==60597== Invalid read of size 4
==60597==at 0x100020BE