From: Kirill Shchetiniuk <[email protected]>

Signed-off-by: Kirill Shchetiniuk <[email protected]>
---
 src/conf/domain_conf.c | 6 +++---
 src/conf/domain_conf.h | 1 +
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 541dad5bdc..02f55ade44 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12277,16 +12277,16 @@ virDomainGraphicsDefParseXMLDBus(virDomainGraphicsDef 
*def,
 virDomainGraphicsDef *
 virDomainGraphicsDefNew(virDomainXMLOption *xmlopt)
 {
-    virDomainGraphicsDef *def = NULL;
+    g_autoptr(virDomainGraphicsDef) def = NULL;
 
     def = g_new0(virDomainGraphicsDef, 1);
 
     if (xmlopt && xmlopt->privateData.graphicsNew &&
         !(def->privateData = xmlopt->privateData.graphicsNew())) {
-        VIR_FREE(def);
+        return NULL;
     }
 
-    return def;
+    return g_steal_pointer(&def);
 }
 
 
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index cb35ff06bd..185fc959aa 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3726,6 +3726,7 @@ int virDomainObjWaitUntil(virDomainObj *vm,
 void virDomainPanicDefFree(virDomainPanicDef *panic);
 void virDomainResourceDefFree(virDomainResourceDef *resource);
 void virDomainGraphicsDefFree(virDomainGraphicsDef *def);
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainGraphicsDef, virDomainGraphicsDefFree);
 const char *virDomainInputDefGetPath(virDomainInputDef *input);
 void virDomainInputDefFree(virDomainInputDef *def);
 virDomainDiskDef *virDomainDiskDefNew(virDomainXMLOption *xmlopt);
-- 
2.49.0

Reply via email to