diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2011-02-02 10:31:18 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2011-02-02 10:31:18 -0500 |
commit | b159829e12ce30c6343b43c2ea48c4985f4f3731 (patch) | |
tree | e675d67a28976e8d264b78318849fc58527ac43e /netlib.c | |
parent | 2e38c5204a2461e1c033426e3213d860f3487f94 (diff) | |
download | gpsd-b159829e12ce30c6343b43c2ea48c4985f4f3731.tar.gz |
Guard a potentially fatal call better. All regression tests pass.
Diffstat (limited to 'netlib.c')
-rw-r--r-- | netlib.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -76,7 +76,8 @@ socket_t netlib_connectsock(int af, const char *host, const char *service, else if (setsockopt (s, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(one)) == -1) { - (void)close(s); + if (s > -1) + (void)close(s); ret = NL_NOSOCKOPT; } else { if (bind_me) { @@ -92,7 +93,7 @@ socket_t netlib_connectsock(int af, const char *host, const char *service, } } - if (s > 0) { + if (s > -1) { (void)close(s); } } |