net: set *fd to -1 if operation failed, check fd value in net_close()
commitfc3bf2334236f1da72126e5864ec97c703e4ca4f
authorWilliam Smith <wsmith1@mail.ru>
Fri, 18 Jan 2013 02:27:32 +0000 (17 21:27 -0500)
committerWilliam Smith <wsmith1@mail.ru>
Fri, 18 Jan 2013 02:45:02 +0000 (17 21:45 -0500)
tree8d746a9244927f6587a6efb4d890e1d0f64e7f6d
parent02f24ed289b4e9d750fb4eaa057bdfd879c95887
net: set *fd to -1 if operation failed, check fd value in net_close()

Set *fd to -1 in net_connect() and net_bind() if any of
the operations failed and close() was called on *fd. This
ensures that *fd is set to a valid file descriptor only
if all operations succeeded.

Check fd value in net_close(), only perform the shutdown
and close only on non-negative fd values.
library/net.c