On 1/8/19 4:36 AM, Grisha Levit wrote:
> A couple silly function attribute manipulations lead to situations that
> result in segfaults:

Thanks for the report.

> 
> $ f() { :; }; declare -Af f; declare -pf f
> [ segfault ]
> 
> diff --git a/builtins/setattr.def b/builtins/setattr.def
> index 251bcacb..1a828291 100644
> --- a/builtins/setattr.def
> +++ b/builtins/setattr.def
> @@ -474,9 +474,9 @@ show_var_attributes (var, pattr, nodefs)
>  #if defined (ARRAY_VARS)
>    if (invisible_p (var) && (array_p (var) || assoc_p (var)))
>      printf ("%s\n", var->name);
> -  else if (array_p (var))
> +  else if (array_p (var) && function_p (var) == 0)
>      print_array_assignment (var, 0);
> -  else if (assoc_p (var))
> +  else if (assoc_p (var) && function_p (var) == 0)
>      print_assoc_assignment (var, 0);
>    else
>  #endif
> 
> (Maybe the better solution would be to prevent meaningless attributes from
> getting assigned to functions in the first place, but they seem harmless
> otherwise).

I prefer:

$ ./bash ./x19
./x19: line 1: declare: f: -A? Oh, come on.
f ()
{
    :
}


-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/

Reply via email to