mirror of
https://github.com/SELinuxProject/selinux
synced 2024-12-22 14:02:17 +00:00
semodule_link: avoid NULL dereference on OOM
In case the initial calloc(3) call fails the variable mods is still NULL
while its size hint num_mods is set.
Reported by Clang Analyzer:
semodule_link.c:182:29: warning: Array access (from variable 'mods') results in a null pointer dereference [core.NullDereference]
182 | sepol_module_package_free(mods[i]);
| ^~~~~~~
Fixes: 63e798a203
("semodule_link: update")
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
This commit is contained in:
parent
de491fda3d
commit
8547846ecd
@ -178,9 +178,11 @@ failure:
|
||||
ret = EXIT_FAILURE;
|
||||
|
||||
cleanup:
|
||||
for (i = 0; i < num_mods; i++)
|
||||
sepol_module_package_free(mods[i]);
|
||||
free(mods);
|
||||
if (mods) {
|
||||
for (i = 0; i < num_mods; i++)
|
||||
sepol_module_package_free(mods[i]);
|
||||
free(mods);
|
||||
}
|
||||
sepol_module_package_free(base);
|
||||
|
||||
return ret;
|
||||
|
Loading…
Reference in New Issue
Block a user