mirror of https://github.com/python/cpython.git
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)
This commit is contained in:
parent
a312c3ade7
commit
e1c478ff8a
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue