summaryrefslogtreecommitdiffstats
path: root/Modules/socketmodule.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-06-06 20:10:16 (GMT)
committerGuido van Rossum <guido@python.org>2002-06-06 20:10:16 (GMT)
commit93f2edba15da3ec98e4f7a7964400466e97b52c8 (patch)
tree42b658bdf2be44d0e3c0db879db3d9879fac6835 /Modules/socketmodule.c
parent56b36cdca14b10bc95a7840993dffa0eae4029cc (diff)
downloadcpython-93f2edba15da3ec98e4f7a7964400466e97b52c8.zip
cpython-93f2edba15da3ec98e4f7a7964400466e97b52c8.tar.gz
cpython-93f2edba15da3ec98e4f7a7964400466e97b52c8.tar.bz2
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)
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r--Modules/socketmodule.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 47ddcd5..172a507 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;
}