]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport:
authorGuido van Rossum <guido@python.org>
Thu, 6 Jun 2002 20:10:16 +0000 (20:10 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 6 Jun 2002 20:10:16 +0000 (20:10 +0000)
The tp_new implementation should initialize the errorhandler field,
otherwise this code could segfault:

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

Modules/socketmodule.c

index 47ddcd54141d0b55bfce3374e638ab9b19a7fe63..172a507e87f24d82b948a97a5ea1ec305f87b124 100644 (file)
@@ -1800,8 +1800,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;
 }