[libvirt PATCH] tests: Use freecon in testSELinuxCheckLabels

Jiri Denemark jdenemar at redhat.com
Fri Feb 11 13:34:04 UTC 2022


This partially reverts commit 0fc4a43d248b86fd54ad7323beb66faec8c1043c.

Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
---
 tests/securityselinuxlabeltest.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabeltest.c
index dfe9d38d34..83532d8090 100644
--- a/tests/securityselinuxlabeltest.c
+++ b/tests/securityselinuxlabeltest.c
@@ -230,7 +230,7 @@ testSELinuxCheckLabels(testSELinuxFile *files, size_t nfiles)
     size_t i;
 
     for (i = 0; i < nfiles; i++) {
-        g_autofree char *ctx = NULL;
+        char *ctx = NULL;
         if (getfilecon(files[i].file, &ctx) < 0) {
             if (errno == ENODATA) {
                 /* nothing to do */
@@ -247,8 +247,10 @@ testSELinuxCheckLabels(testSELinuxFile *files, size_t nfiles)
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            "File %s context '%s' did not match expected '%s'",
                            files[i].file, ctx, files[i].context);
+            freecon(ctx);
             return -1;
         }
+        freecon(ctx);
     }
     return 0;
 }
-- 
2.35.0




More information about the libvir-list mailing list