[libvirt] [PATCH 2/9] openvz: Convert virExec usage to virCommand
Eric Blake
eblake at redhat.com
Tue May 17 15:12:13 UTC 2011
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 at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110517/66e10622/attachment-0001.sig>
More information about the libvir-list
mailing list