提交 cb9bd796 编写于 作者: E Eric Blake

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: NEric Blake <eblake@redhat.com>
上级 2c4870d0
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册