Re: [PATCH 2/9] openvz: Convert virExec usage to virCommand

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

 



On 05/17/2011 08:24 AM, Cole Robinson wrote:
>>> +    rc = got;
>>>  out:
>>>      VIR_FORCE_CLOSE(outfd);
>>> +    virCommandFree(cmd);
>>>      for ( ; got >= 0 ; got--)
>>>          VIR_FREE(names[got]);
>>
>> Oops, this now frees names[] on success.  You need to gate this for loop
>> on whether rc >= 0, now that the success path falls through to the out
>> label.
>>
>> ACK with that nit fixed.
>>
> 
> Thanks, pushed with that fix.

Phooey, we got it backwards.   On success, we want names[0] to be valid.
 On failure, we want names[0] to be NULL.

So the condition needs to be if (rc < 0) { free names }.

I'm pushing this followup under the trivial rule:

diff --git i/src/openvz/openvz_driver.c w/src/openvz/openvz_driver.c
index cefba16..ae951a2 100644
--- i/src/openvz/openvz_driver.c
+++ w/src/openvz/openvz_driver.c
@@ -1492,7 +1492,7 @@ static int openvzListDefinedDomains(virConnectPtr
conn ATTRIBUTE_UNUSED,
 out:
     VIR_FORCE_CLOSE(outfd);
     virCommandFree(cmd);
-    if (rc >= 0) {
+    if (rc < 0) {
         for ( ; got >= 0 ; got--)
             VIR_FREE(names[got]);
     }


-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]