From: John Ferlan Date: Thu, 11 Jul 2013 11:19:37 +0000 (-0400) Subject: hellolibvirt: Resolve Coverity issues X-Git-Tag: CVE-2013-4154~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0776809659ea014f325e862fe441b5a43be3de9e;p=thirdparty%2Flibvirt.git hellolibvirt: Resolve Coverity issues Recent changes uncovered a NEGATIVE_RETURNS when processing 'numNames' in 'showDomains' in the for loop after a possible -1 return. --- diff --git a/examples/hellolibvirt/hellolibvirt.c b/examples/hellolibvirt/hellolibvirt.c index 83045b1dc4..0179fad35d 100644 --- a/examples/hellolibvirt/hellolibvirt.c +++ b/examples/hellolibvirt/hellolibvirt.c @@ -90,6 +90,13 @@ showDomains(virConnectPtr conn) numNames = virConnectListAllDomains(conn, &nameList, flags); + if (numNames == -1) { + ret = 1; + printf("Failed to get a list of all domains: %s\n", + virGetLastErrorMessage()); + goto out; + } + for (i = 0; i < numNames; i++) { int active = virDomainIsActive(nameList[i]); printf(" %8s (%s)\n",