[libvirt] [PATCH] virDomainNetDefParseXML: avoid leak upon multiple "filterref"

Jim Meyering jim at meyering.net
Tue May 18 17:25:50 UTC 2010


Stefan Berger wrote:
> On Tue, 2010-05-18 at 08:22 -0600, Eric Blake wrote:
>> On 05/18/2010 02:22 AM, Jim Meyering wrote:
>> > * 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);
>>
>> ACK.
>
> Don't want this to be the only 'free', make it a VIR_FREE().

The only difference is that VIR_FREE also zeros its argument.
That's not needed when the next statement sets that same variable.
However, considering there are already 254 uses of VIR_FREE
in that file, and none of "free", I can't resist making it an
even 0xFF and have switched it to conform.




More information about the libvir-list mailing list