diff mbox series

libselinux: Fix ordering of arguments to calloc

Message ID 20240105201917.2286119-1-jwcart2@gmail.com (mailing list archive)
State Accepted
Commit dfe30d9d0190
Delegated to: Petr Lautrbach
Headers show
Series libselinux: Fix ordering of arguments to calloc | expand

Commit Message

James Carter Jan. 5, 2024, 8:19 p.m. UTC
The number of elements should be first and the size of the elements
second.

Signed-off-by: James Carter <jwcart2@gmail.com>
---
 libselinux/src/audit2why.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

James Carter Jan. 25, 2024, 7:58 p.m. UTC | #1
On Fri, Jan 5, 2024 at 3:19 PM James Carter <jwcart2@gmail.com> wrote:
>
> The number of elements should be first and the size of the elements
> second.
>
> Signed-off-by: James Carter <jwcart2@gmail.com>

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
>
diff mbox series

Patch

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);