libsepol: do not seg fault on sepol_*_key_free(NULL)

sepol_*_key_free(NULL) should just be a no-op just like
free(NULL).  Fix several instances that did not handle this
correctly and would seg fault if called with NULL.

Test: setsebool -P zebra_write_config=1 while non-root

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
This commit is contained in:
Stephen Smalley 2017-04-07 11:01:52 -04:00
parent 92f22e193a
commit e6edc42455
3 changed files with 6 additions and 0 deletions

View File

@ -67,6 +67,8 @@ int sepol_bool_key_extract(sepol_handle_t * handle,
void sepol_bool_key_free(sepol_bool_key_t * key)
{
if (!key)
return;
free(key->name);
free(key);
}

View File

@ -73,6 +73,8 @@ int sepol_iface_key_extract(sepol_handle_t * handle,
void sepol_iface_key_free(sepol_iface_key_t * key)
{
if (!key)
return;
free(key->name);
free(key);
}

View File

@ -76,6 +76,8 @@ int sepol_user_key_extract(sepol_handle_t * handle,
void sepol_user_key_free(sepol_user_key_t * key)
{
if (!key)
return;
free(key->name);
free(key);
}