Coverity notes that if the virConnectListAllDomains returns a negative
value then the loop at the cleanup label that ends on numDomains will
have issues.
Signed-off-by: John Ferlan <jferlan@redhat.com>
ret = -1;
cleanup:
- for (i = 0; i < numDomains; i++)
- virDomainFree(domains[i]);
- VIR_FREE(domains);
+ if (domains) {
+ for (i = 0; i < numDomains; i++)
+ virDomainFree(domains[i]);
+ VIR_FREE(domains);
+ }
VIR_FREE(flags);
virObjectUnref(conn);
virObjectUnref(cfg);