diff options
-rw-r--r-- | Modules/socketmodule.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index cba261e..d5c925b 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -505,9 +505,14 @@ internal_select(PySocketSockObject *s, int writing) fd_set fds; struct timeval tv; + /* Nothing to do unless we're in timeout mode (not non-blocking) */ if (s->sock_timeout <= 0.0) return; + /* Guard against closed socket */ + if (s->sock_fd < 0) + return; + /* Construct the arguments to select */ tv.tv_sec = (int)s->sock_timeout; tv.tv_usec = (int)((s->sock_timeout - tv.tv_sec) * 1e6); |