The offending code below appears in this loop:
virNWFilterHashTablePtr filterparams = NULL;
...
cur = node->children;
while (cur != NULL) {
...
}
so the first assignment works fine, but second and subsequent
ones leak the buffer returned by each preceding
virNWFilterParseParamAttributes call.
From 8659fb1ae879befe360e1ec7b8b62434c22698cd Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 18 May 2010 10:19:30 +0200
Subject: [PATCH] virDomainNetDefParseXML: avoid leak upon multiple "filterref"
* src/conf/domain_conf.c (virDomainNetDefParseXML): Don't leak
memory when parsing two or more "filterref" elements.
---
src/conf/domain_conf.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3e45f79..0c717f2 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1905,6 +1905,7 @@ virDomainNetDefParseXML(virCapsPtr caps,
model = virXMLPropString(cur, "type");
} else if (xmlStrEqual (cur->name, BAD_CAST "filterref")) {
filter = virXMLPropString(cur, "filter");
+ free(filterparams);
filterparams = virNWFilterParseParamAttributes(cur);
} else if ((flags & VIR_DOMAIN_XML_INTERNAL_STATUS) &&
xmlStrEqual(cur->name, BAD_CAST "state")) {
--
1.7.1.250.g7d1e8