Skip to content

Commit

Permalink
libselinux: Fix ordering of arguments to calloc
Browse files Browse the repository at this point in the history
The number of elements should be first and the size of the elements
second.

Signed-off-by: James Carter <[email protected]>
  • Loading branch information
jwcart2 committed Jan 25, 2024
1 parent 114f1bb commit dfe30d9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libselinux/src/audit2why.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit dfe30d9

Please sign in to comment.