summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-07-19 12:44:59 (GMT)
committerGuido van Rossum <guido@python.org>2002-07-19 12:44:59 (GMT)
commitad654906288a1ed985b8649c75a9c6037448cb9d (patch)
treed9e227dcac9c35623553bf3f1758d1a34cad5ff9 /Modules
parent330f9e9581a5d97a0560f10182ae882b07eb3c66 (diff)
downloadcpython-ad654906288a1ed985b8649c75a9c6037448cb9d.zip
cpython-ad654906288a1ed985b8649c75a9c6037448cb9d.tar.gz
cpython-ad654906288a1ed985b8649c75a9c6037448cb9d.tar.bz2
Bail out early from internal_select() when socket file descriptor
closed. Prevents core dump.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/socketmodule.c5
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);