summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordoug <doug@openbsd.org>2015-07-19 03:28:26 +0000
committerdoug <doug@openbsd.org>2015-07-19 03:28:26 +0000
commit0a17e2613402b744e7367759e6606e4829b078d4 (patch)
treece6b7c0ba0892c719e3558c3cc211b736ab35979
parentFree variable before potentially reusing. (diff)
downloadwireguard-openbsd-0a17e2613402b744e7367759e6606e4829b078d4.tar.xz
wireguard-openbsd-0a17e2613402b744e7367759e6606e4829b078d4.zip
Only close descriptor if not already closed.
Fixes coverity 78916. ok miod@ bcook@
-rw-r--r--usr.bin/openssl/s_socket.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/openssl/s_socket.c b/usr.bin/openssl/s_socket.c
index c49edf1d4e6..ccf49c5da5b 100644
--- a/usr.bin/openssl/s_socket.c
+++ b/usr.bin/openssl/s_socket.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: s_socket.c,v 1.5 2015/07/17 20:22:02 beck Exp $ */
+/* $OpenBSD: s_socket.c,v 1.6 2015/07/19 03:28:26 doug Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -83,7 +83,7 @@ int
init_client(int *sock, char *host, char *port, int type, int af)
{
struct addrinfo hints, *ai_top, *ai;
- int i, s;
+ int i, s = -1;
memset(&hints, '\0', sizeof(hints));
hints.ai_family = af;
@@ -120,11 +120,13 @@ init_client(int *sock, char *host, char *port, int type, int af)
return (1);
}
close(s);
+ s = -1;
}
perror("connect");
out:
- close(s);
+ if (s != -1)
+ close(s);
freeaddrinfo(ai_top);
return (0);
}