Skip to content

Commit

Permalink
libsemanage: Fix RESOURCE_LEAK and USE_AFTER_FREE coverity scan defects
Browse files Browse the repository at this point in the history
  • Loading branch information
bachradsusi authored and Thaodan committed Oct 13, 2020
1 parent 636fc4b commit f2dcac4
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions libsemanage/src/direct_api.c
Expand Up @@ -1028,7 +1028,7 @@ static int semanage_direct_write_langext(semanage_handle_t *sh,

fp = NULL;

ret = 0;
return 0;

cleanup:
if (fp != NULL) fclose(fp);
Expand Down Expand Up @@ -2184,7 +2184,6 @@ static int semanage_direct_set_enabled(semanage_handle_t *sh,
semanage_module_info_destroy(sh, modinfo);
free(modinfo);

if (fp != NULL) fclose(fp);
return status;
}

Expand Down Expand Up @@ -2349,16 +2348,6 @@ static int semanage_direct_get_module_info(semanage_handle_t *sh,
free(tmp);
tmp = NULL;

if (fclose(fp) != 0) {
ERR(sh,
"Unable to close %s module lang ext file.",
(*modinfo)->name);
status = -1;
goto cleanup;
}

fp = NULL;

/* lookup enabled/disabled status */
ret = semanage_module_get_path(sh,
*modinfo,
Expand Down Expand Up @@ -2402,7 +2391,13 @@ static int semanage_direct_get_module_info(semanage_handle_t *sh,
free(modinfos);
}

if (fp != NULL) fclose(fp);
if (fp != NULL && fclose(fp) != 0) {
ERR(sh,
"Unable to close %s module lang ext file.",
(*modinfo)->name);
status = -1;
}

return status;
}

Expand Down

0 comments on commit f2dcac4

Please sign in to comment.