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)