Make sure the error handler (i.e. the code after the 'cleanup' label)
does not attempt to call close(-1), in case 'sockfd' is not initialized
yet.
---
p2v/nbd.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/p2v/nbd.c b/p2v/nbd.c
index ee21005..29ca40d 100644
--- a/p2v/nbd.c
+++ b/p2v/nbd.c
@@ -722,7 +722,8 @@ wait_for_nbd_server_to_start (const char *ipaddr, int port)
result = 0;
cleanup:
- close (sockfd);
+ if (sockfd >= 0)
+ close (sockfd);
return result;
}
--
2.9.3