[PATCH 02/12] storage_conf: Don't leak "uuid" in virStoragePoolDefParseAuthCephx

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

 



Any string returned from virXPathString should be freed.
---
 src/conf/storage_conf.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index bd8eef0..073099b 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -466,6 +466,8 @@ virStoragePoolDefParseAuthCephx(xmlXPathContextPtr ctxt,
                                 virStoragePoolAuthCephxPtr auth)
 {
     char *uuid = NULL;
+    int ret = -1;
+
     auth->username = virXPathString("string(./auth/@username)", ctxt);
     if (auth->username == NULL) {
         virReportError(VIR_ERR_XML_ERROR,
@@ -485,19 +487,22 @@ virStoragePoolDefParseAuthCephx(xmlXPathContextPtr ctxt,
         if (auth->secret.usage != NULL) {
             virReportError(VIR_ERR_XML_ERROR, "%s",
                            _("either auth secret uuid or usage expected"));
-            return -1;
+            goto cleanup;
         }
         if (virUUIDParse(uuid, auth->secret.uuid) < 0) {
             virReportError(VIR_ERR_XML_ERROR,
                            "%s", _("invalid auth secret uuid"));
-            return -1;
+            goto cleanup;
         }
         auth->secret.uuidUsable = true;
     } else {
         auth->secret.uuidUsable = false;
     }
 
-    return 0;
+    ret = 0;
+cleanup:
+    VIR_FREE(uuid);
+    return ret;
 }
 
 static int
-- 
1.8.1.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]