libsepol: use the number of elements in calloc first argument
When allocating an array with calloc(), the first argument usually is the number of items and the second one the size of an item. Doing so silences a warning reported by clang's static analyzer: kernel_to_cil.c:2050:14: warning: Call to 'calloc' has an allocation size of 0 bytes. cond_data = calloc(sizeof(struct cond_data), num); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
This commit is contained in:
parent
d00cc13483
commit
bfd61a3ec7
|
@ -2043,7 +2043,7 @@ static int write_cond_nodes_to_cil(FILE *out, struct policydb *pdb)
|
|||
num++;
|
||||
}
|
||||
|
||||
cond_data = calloc(sizeof(struct cond_data), num);
|
||||
cond_data = calloc(num, sizeof(struct cond_data));
|
||||
if (!cond_data) {
|
||||
rc = -1;
|
||||
goto exit;
|
||||
|
|
Loading…
Reference in New Issue