
On 05/17/2011 11:12 AM, Eric Blake wrote:
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]); }
Urgh sorry, thanks for confirming the correct fix. - Cole