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:
Guido van Rossum 2002-06-06 20:08:25 +00:00
parent a312c3ade7
commit e1c478ff8a
1 changed files with 3 additions and 1 deletions

View File

@ -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;
}