mirror of
https://github.com/python/cpython.git
synced 2025-07-15 23:35:23 +00:00
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
1 changed files with 3 additions and 1 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue