]> granicus.if.org Git - python/commitdiff
The tp_new implementation should initialize the errorhandler field,
authorGuido van Rossum <guido@python.org>
Thu, 6 Jun 2002 20:08:25 +0000 (20:08 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 6 Jun 2002 20:08:25 +0000 (20:08 +0000)
otherwise this code could segfault:

  from socket import socket
  s = socket.__new__(socket)
  s.recv(100)

Modules/socketmodule.c

index 21fcab0538d86e766ea9b2d86c6a88b939ae8a39..1874541bb1cc6b92bef457a04f772bfd6f21c687 100644 (file)
@@ -1690,8 +1690,10 @@ PySocketSock_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
        PyObject *new;
 
        new = type->tp_alloc(type, 0);
-       if (new != NULL)
+       if (new != NULL) {
                ((PySocketSockObject *)new)->sock_fd = -1;
+               ((PySocketSockObject *)new)->errorhandler = &PySocket_Err;
+       }
        return new;
 }