From: Ján Tomko Date: Tue, 4 Feb 2020 23:58:52 +0000 (+0100) Subject: conf: use correct free function for virDomainDeviceDef X-Git-Tag: v6.1.0-rc1~222 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f40a487a9a820004214574f82f0e492a836adf0;p=thirdparty%2Flibvirt.git conf: use correct free function for virDomainDeviceDef Simple g_autofree is not enough if we put allocated data into the device structure. Define the AUTOPTR_CLEANUP function and use it here. Signed-off-by: Ján Tomko Reported-by: Xu Yandong Reviewed-by: Peter Krempa --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c95bd34fb5..c3214dc4f3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16516,7 +16516,7 @@ virDomainDeviceDefParse(const char *xmlStr, g_autoptr(xmlDoc) xml = NULL; xmlNodePtr node; g_autoptr(xmlXPathContext) ctxt = NULL; - g_autofree virDomainDeviceDefPtr dev = NULL; + g_autoptr(virDomainDeviceDef) dev = NULL; if (!(xml = virXMLParseStringCtxt(xmlStr, _("(device_definition)"), &ctxt))) return NULL; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e144f3aad3..c3acb29e6f 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2916,6 +2916,7 @@ void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def); void virDomainRedirFilterDefFree(virDomainRedirFilterDefPtr def); void virDomainShmemDefFree(virDomainShmemDefPtr def); void virDomainDeviceDefFree(virDomainDeviceDefPtr def); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainDeviceDef, virDomainDeviceDefFree); virDomainDeviceDefPtr virDomainDeviceDefCopy(virDomainDeviceDefPtr src, const virDomainDef *def, virDomainXMLOptionPtr xmlopt,