On Sun, Mar 26, 2023 at 08:19:25AM +0200, Emanuele Torre wrote:
> -        sa = xmalloc(n * sizeof(sort_element));
> +        if (n)
> +          sa = xmalloc (n * sizeof(sort_element));
>          i = 0;
>          for ( j = 0; j < hash->nbuckets; ++j ) {
>              bucket = hash->bucket_array[j];
> @@ -91,7 +92,8 @@ sort_index(SHELL_VAR *dest, SHELL_VAR *source)
>      else {
>          array = array_cell(source);
>          n = array_num_elements(array);
> -        sa = xmalloc(n * sizeof(sort_element));
> +        if (n)
> +          sa = xmalloc (n * sizeof(sort_element));

Oops, those should be

  sa = n ? xmalloc (n * sizeof(sort_element)) : NULL;

Reply via email to