mirror of
https://github.com/SELinuxProject/selinux
synced 2025-02-03 19:32:15 +00:00
libsemanage: do not dereference a NULL pointer when calloc() fails
If "names = calloc(num_modinfos, sizeof(*names))" fails in semanage_get_cil_paths(), the function tries to frees items in array "names" even though it is NULL. Avoid this by returning directly. This issue has been found using clang's static analyzer. Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
This commit is contained in:
parent
0438d5c421
commit
85da6194ea
@ -1012,8 +1012,7 @@ int semanage_get_cil_paths(semanage_handle_t * sh,
|
|||||||
names = calloc(num_modinfos, sizeof(*names));
|
names = calloc(num_modinfos, sizeof(*names));
|
||||||
if (names == NULL) {
|
if (names == NULL) {
|
||||||
ERR(sh, "Error allocating space for filenames.");
|
ERR(sh, "Error allocating space for filenames.");
|
||||||
status = -1;
|
return -1;
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < num_modinfos; i++) {
|
for (i = 0; i < num_modinfos; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user