From e1c478ff8a8cbae86dbc5467ccfe8c01bac52a54 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Thu, 6 Jun 2002 20:08:25 +0000 Subject: [PATCH] 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 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 21fcab0538d..1874541bb1c 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -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; }