selinux: update mac_selinux_free()

* Drop mac_selinux_use() condition from mac_selinux_free(): if the
  passed pointer holds memory we want to free it even if SELinux is
  disabled

* Drop NULL-check cause man:freecon(3) states that freecon(NULL) is a
  well-defined NOP

* Assert that on non-SELinux builds the passed pointer is always NULL,
  to avoid memory leaks
This commit is contained in:
Christian Göttsche 2020-06-23 12:26:59 +02:00 committed by Lennart Poettering
parent 1cdc42f283
commit 3d9fbea43e

View file

@ -376,13 +376,9 @@ int mac_selinux_get_child_mls_label(int socket_fd, const char *exe, const char *
char* mac_selinux_free(char *label) {
#if HAVE_SELINUX
if (!label)
return NULL;
if (!mac_selinux_use())
return NULL;
freecon(label);
#else
assert(!label);
#endif
return NULL;