libsemanage: Fix null pointer dereference in semanage_module_key_destroy

If modkey is NULL, semanage_module_key_destroy() would still try to
initialize a modkey after freeing it.

Signed-off-by: Yuli Khodorkovskiy <ykhodorkovskiy@tresys.com>
Signed-off-by: James Carter <jwcart2@tycho.nsa.gov>
This commit is contained in:
Yuli Khodorkovskiy 2015-08-06 10:30:13 -04:00 committed by James Carter
parent 228261a51a
commit d4f3ba7c50

View File

@ -690,10 +690,12 @@ int semanage_module_key_destroy(semanage_handle_t *sh,
{
assert(sh);
if (modkey) {
free(modkey->name);
if (!modkey) {
return 0;
}
free(modkey->name);
return semanage_module_key_init(sh, modkey);
}