[glib: 3/5] gio: remove unnecessary strdup and fix potential leak




commit f9cc77da73a0ad2ebe5998aa3c5509e3ab941510
Author: Marc-André Lureau <marcandre lureau redhat com>
Date:   Tue Dec 1 12:57:58 2020 +0400

    gio: remove unnecessary strdup and fix potential leak
    
    setfilecon_raw() takes a const argument since libselinux 2.2 (commit
    https://github.com/SELinuxProject/selinux/commit/6a17cfaafcdab82c9909eccff56968913b36a631)
    
    Signed-off-by: Marc-André Lureau <marcandre lureau redhat com>

 gio/glocalfileinfo.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
---
diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c
index 32a26d1b2..987ed280e 100644
--- a/gio/glocalfileinfo.c
+++ b/gio/glocalfileinfo.c
@@ -2715,11 +2715,7 @@ set_selinux_context (char                       *filename,
   }
 
   if (is_selinux_enabled ()) {
-       char *val_s;
-       
-       val_s = g_strdup (val);
-       
-       if (setfilecon_raw (filename, val_s) < 0)
+       if (setfilecon_raw (filename, val) < 0)
        {
             int errsv = errno;
             
@@ -2729,7 +2725,6 @@ set_selinux_context (char                       *filename,
                          g_strerror (errsv));
             return FALSE;
         }
-        g_free (val_s);
   } else {
     g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
                          _("SELinux is not enabled on this system"));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]