]> granicus.if.org Git - python/commitdiff
Bail out early from internal_select() when socket file descriptor
authorGuido van Rossum <guido@python.org>
Fri, 19 Jul 2002 12:44:59 +0000 (12:44 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 19 Jul 2002 12:44:59 +0000 (12:44 +0000)
closed.  Prevents core dump.

Modules/socketmodule.c

index cba261e85cdcc3f85dbb13561d5445baeec42e47..d5c925b79f910c38c4d90f43d2d6ffb7487a372b 100644 (file)
@@ -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);