From: Michal Privoznik <mprivozn@redhat.com> Inside of testCompareXMLToConfFiles() the network definition is parsed and if that succeeds a virNetworkObj is created by calling virNetworkObjNew(). But if the latter fails, the control jumps onto the fail label where only the object is freed but not already parsed definition leading to a leak. Swapping these two steps ensures that if either of them fails no memleak occurs. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tests/networkxml2conftest.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c index 67856f2e8c..d089ff38b1 100644 --- a/tests/networkxml2conftest.c +++ b/tests/networkxml2conftest.c @@ -33,17 +33,17 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf, if (!(xmlopt = networkDnsmasqCreateXMLConf())) goto fail; - if (!(def = virNetworkDefParse(NULL, inxml, xmlopt, false))) - goto fail; - - if (networkValidateTests(def) < 0) - goto fail; - if (!(obj = virNetworkObjNew())) goto fail; + if (!(def = virNetworkDefParse(NULL, inxml, xmlopt, false))) + goto fail; + virNetworkObjSetDef(obj, def); + if (networkValidateTests(def) < 0) + goto fail; + if (!networkNeedsDnsmasq(def)) { VIR_TEST_VERBOSE("spurious request to generate conf files. Would not start dnsmasq in real life scenario"); goto fail; -- 2.52.0