[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] asort: some bug fixes
From: |
Emanuele Torre |
Subject: |
Re: [PATCH] asort: some bug fixes |
Date: |
Sun, 26 Mar 2023 08:31:22 +0200 |
User-agent: |
Mutt/2.2.9 (2022-11-12) |
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;