[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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



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 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 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

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]