libsemanage: Fix USE_AFTER_FREE (CWE-672) in semanage_direct_get_module_info()

>From fclose(3):
Upon successful completion, 0 is returned.  Otherwise, EOF is returned
and errno is set to indicate the error. In either case, any further
access (including another call to fclose()) to the stream results in
undefined behavior.

Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
Acked-by: James Carter <jwcart2@gmail.com>
This commit is contained in:
Petr Lautrbach 2022-04-01 15:35:47 +02:00
parent 8aca100c5b
commit 28510556f8
1 changed files with 1 additions and 0 deletions

View File

@ -2293,6 +2293,7 @@ static int semanage_direct_get_module_info(semanage_handle_t *sh,
tmp = NULL;
if (fclose(fp) != 0) {
fp = NULL;
ERR(sh,
"Unable to close %s module lang ext file.",
(*modinfo)->name);