summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-06-06 20:08:25 (GMT)
committerGuido van Rossum <guido@python.org>2002-06-06 20:08:25 (GMT)
commite1c478ff8a8cbae86dbc5467ccfe8c01bac52a54 (patch)
tree23cdd848a20f1d1b75a0c439893c7b1c93a9c862
parenta312c3ade77a5852c00fd4216626d0423272904a (diff)
downloadcpython-e1c478ff8a8cbae86dbc5467ccfe8c01bac52a54.zip
cpython-e1c478ff8a8cbae86dbc5467ccfe8c01bac52a54.tar.gz
cpython-e1c478ff8a8cbae86dbc5467ccfe8c01bac52a54.tar.bz2
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)
-rw-r--r--Modules/socketmodule.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 21fcab0..1874541 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;
}