]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virSecurityLabelDefParseXML: Use automatic freeing for 'seclabel'
authorPeter Krempa <pkrempa@redhat.com>
Mon, 22 Nov 2021 15:40:33 +0000 (16:40 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 24 Nov 2021 08:20:39 +0000 (09:20 +0100)
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/domain_conf.c

index df0d033d0b121ba0d3cc0cf0d476aab25cd8deb8..99bee98df8cede1a5e9c45b0f6b8f487d0db4541 100644 (file)
@@ -7802,7 +7802,7 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt,
 {
     g_autofree char *model = NULL;
     g_autofree char *relabel = NULL;
-    virSecurityLabelDef *seclabel = NULL;
+    g_autoptr(virSecurityLabelDef) seclabel = NULL;
 
     model = virXMLPropStringLimit(ctxt->node, "model",
                                   VIR_SECURITY_MODEL_BUFLEN - 1);
@@ -7862,7 +7862,7 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt,
             /* combination of relabel='yes' and type='static'
              * is checked a few lines above. */
         }
-        return seclabel;
+        return g_steal_pointer(&seclabel);
     }
 
     /* Only parse label, if using static labels, or
@@ -7899,10 +7899,9 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt,
                                                   VIR_SECURITY_LABEL_BUFLEN-1, ctxt);
     }
 
-    return seclabel;
+    return g_steal_pointer(&seclabel);
 
  error:
-    virSecurityLabelDefFree(seclabel);
     return NULL;
 }