Re: [PATCH] libselinux: Fix ordering of arguments to calloc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 5, 2024 at 3:19 PM James Carter <jwcart2@xxxxxxxxx> wrote:
>
> The number of elements should be first and the size of the elements
> second.
>
> Signed-off-by: James Carter <jwcart2@xxxxxxxxx>

This patch has been merged.
Jim

> ---
>  libselinux/src/audit2why.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libselinux/src/audit2why.c b/libselinux/src/audit2why.c
> index 8c4c07d5..ad846cc3 100644
> --- a/libselinux/src/audit2why.c
> +++ b/libselinux/src/audit2why.c
> @@ -148,7 +148,7 @@ static int check_booleans(struct boolean_t **bools)
>                 sepol_bool_free(boolean);
>
>         if (fcnt > 0) {
> -               *bools = calloc(sizeof(struct boolean_t), fcnt + 1);
> +               *bools = calloc(fcnt + 1, sizeof(struct boolean_t));
>                 if (!*bools) {
>                         PyErr_SetString( PyExc_MemoryError, "Out of memory\n");
>                         free(foundlist);
> @@ -226,7 +226,7 @@ static int __policy_init(const char *init_path)
>                 return 1;
>         }
>
> -       avc = calloc(sizeof(struct avc_t), 1);
> +       avc = calloc(1, sizeof(struct avc_t));
>         if (!avc) {
>                 PyErr_SetString( PyExc_MemoryError, "Out of memory\n");
>                 fclose(fp);
> --
> 2.43.0
>





[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux