[libvirt] [PATCH 11/23] Fix leak of iterators in virDBusMessageIterEncode

Eric Blake eblake at redhat.com
Wed Sep 25 16:57:58 UTC 2013


On 09/25/2013 10:54 AM, Daniel P. Berrange wrote:
> On Wed, Sep 25, 2013 at 10:45:00AM -0600, Eric Blake wrote:
>> On 09/25/2013 08:51 AM, Daniel P. Berrange wrote:
>>> From: "Daniel P. Berrange" <berrange at redhat.com>
>>>
>>> If virDBusMessageIterEncode hits an OOM condition it often
>>> leaks the memory associated with the dbus iterator object
>>>
>>> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
>>> ---
>>
>>>  
>>>  cleanup:
>>> +    while (nstack > 0) {
>>> +        DBusMessageIter *thisiter = iter;
>>> +        VIR_DEBUG("Popping iter=%p", iter);
>>> +        if (virDBusTypeStackPop(&stack, &nstack, &iter,
>>> +                                &types, &nstruct, &narray) < 0)
>>> +            goto cleanup;
>>
>> I'm worried that this will infloop.  What guarantee do we have that
>> nstack reduces when virDBusTypeStackPop fails?
> 
> It can only return -1, if nstack == 0, so I think we're fine there

But you already checked that nstack was > 0.  So write it:

ignore_value(virDBusTypeStackPop(...));

rather than the confusing dead-code backwards goto.

ACK with that change.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130925/2c38d26e/attachment-0001.sig>


More information about the libvir-list mailing list