From: Guido van Rossum Date: Thu, 6 Jun 2002 20:10:16 +0000 (+0000) Subject: Backport: X-Git-Tag: v2.2.2b1~339 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=93f2edba15da3ec98e4f7a7964400466e97b52c8;p=thirdparty%2FPython%2Fcpython.git Backport: 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) --- diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 47ddcd54141d..172a507e87f2 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -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; }