[PATCH v3 1/4] security_apparmor: fix memleaks in AppArmorSetFDLabel

Georgia Garcia posted 4 patches 1 week, 6 days ago
[PATCH v3 1/4] security_apparmor: fix memleaks in AppArmorSetFDLabel
Posted by Georgia Garcia 1 week, 6 days ago
proc and fd_path are allocated but never freed. Fix by using
g_autofree instead.

Fixes: b9757fea30785a92aa95ea675b9bc371e4fb2e8c
Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
---
 src/security/security_apparmor.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c
index eed0f265d6..ae2175d334 100644
--- a/src/security/security_apparmor.c
+++ b/src/security/security_apparmor.c
@@ -1109,8 +1109,8 @@ AppArmorSetFDLabel(virSecurityManager *mgr,
                    virDomainDef *def,
                    int fd)
 {
-    char *proc = NULL;
-    char *fd_path = NULL;
+    g_autofree char *proc = NULL;
+    g_autofree char *fd_path = NULL;
 
     virSecurityLabelDef *secdef =
         virDomainDefGetSecurityLabelDef(def, SECURITY_APPARMOR_NAME);
-- 
2.43.0