gio: remove unnecessary strdup and fix potential leak

setfilecon_raw() takes a const argument since libselinux 2.2 (commit
6a17cfaafc)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
Marc-André Lureau
2020-12-01 12:57:58 +04:00
parent 7bd1e09c42
commit f9cc77da73

View File

@@ -2715,11 +2715,7 @@ set_selinux_context (char *filename,
} }
if (is_selinux_enabled ()) { if (is_selinux_enabled ()) {
char *val_s; if (setfilecon_raw (filename, val) < 0)
val_s = g_strdup (val);
if (setfilecon_raw (filename, val_s) < 0)
{ {
int errsv = errno; int errsv = errno;
@@ -2729,7 +2725,6 @@ set_selinux_context (char *filename,
g_strerror (errsv)); g_strerror (errsv));
return FALSE; return FALSE;
} }
g_free (val_s);
} else { } else {
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
_("SELinux is not enabled on this system")); _("SELinux is not enabled on this system"));