From: Eric Blake Date: Wed, 5 Mar 2014 18:55:27 +0000 (-0700) Subject: virt-login-shell: silence coverity warning X-Git-Tag: v1.2.3-rc1~341 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb9bd7963b2a4c69285d98cc78c6017ec5e2d96e;p=thirdparty%2Flibvirt.git virt-login-shell: silence coverity warning Coverity spotted that 'nfdlist' (ssize_t) could be -1, but that we were using 'i' (size_t) to iterate over the list at cleanup, with crashing results because it promotes to a really big unsigned number. * tools/virt-login-shell.c (main): Avoid treating -1 as unsigned. Signed-off-by: Eric Blake --- diff --git a/tools/virt-login-shell.c b/tools/virt-login-shell.c index 3ea7ade4be..abe7eebdf7 100644 --- a/tools/virt-login-shell.c +++ b/tools/virt-login-shell.c @@ -339,8 +339,9 @@ main(int argc, char **argv) /* At this point, the parent is now waiting for the child to exit, * but as that may take a long time, we release resources now. */ cleanup: - for (i = 0; i < nfdlist; i++) - VIR_FORCE_CLOSE(fdlist[i]); + if (nfdlist > 0) + for (i = 0; i < nfdlist; i++) + VIR_FORCE_CLOSE(fdlist[i]); VIR_FREE(fdlist); virConfFree(conf); if (dom)