]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage_conf: Don't leak "uuid" in virStoragePoolDefParseAuthCephx
authorOsier Yang <jyang@redhat.com>
Wed, 22 May 2013 12:05:12 +0000 (20:05 +0800)
committerOsier Yang <jyang@redhat.com>
Fri, 24 May 2013 14:33:23 +0000 (22:33 +0800)
Any string returned from virXPathString should be freed.

src/conf/storage_conf.c

index 357f8f92cd1efded5a30871179004541b261641e..d8c7282a4cede704bca5431903332f9ab2236cb9 100644 (file)
@@ -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