[libvirt] [PATCH] nwfilter: fix memory leaks
Stefan Berger
stefanb at linux.vnet.ibm.com
Mon Oct 4 10:46:08 UTC 2010
On 10/04/2010 05:23 AM, Matthias Bolte wrote:
> 2010/10/2 Stefan Berger<stefanb at linux.vnet.ibm.com>:
>> Fixing memory leak shown by valgrind and freeing buffer in two more places.
>>
>> Signed-off-by: Stefan Berger<stefanb at us.ibm.com>
>>
>> Index: libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
>> ===================================================================
>> --- libvirt-acl.orig/src/nwfilter/nwfilter_ebiptables_driver.c
>> +++ libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
>> @@ -1508,7 +1508,11 @@ _iptablesCreateRuleInstance(int directio
>> }
>>
>> if (virBufferUse(&prefix)) {
>> - virBufferVSprintf(&prefix, "%s", virBufferContentAndReset(&buf));
>> + char *s = virBufferContentAndReset(&buf);
>> +
>> + virBufferVSprintf(&prefix, "%s", s);
> You could simplify this to use virBufferAdd(&prefix, s, -1) instead of
> virBufferVSprintf.
>
Right, I changed that.
>> +
>> + VIR_FREE(s);
>>
>> final =&prefix;
>>
>> @@ -1531,11 +1535,13 @@ _iptablesCreateRuleInstance(int directio
>>
>> err_exit:
>> virBufferFreeAndReset(&buf);
>> + virBufferFreeAndReset(&prefix);
>>
>> return -1;
>>
>> exit_no_error:
>> virBufferFreeAndReset(&buf);
>> + virBufferFreeAndReset(&prefix);
>>
>> return 0;
>> }
>>
> ACK.
>
> Matthias
Pushed.
Stefan
More information about the libvir-list
mailing list