mirror of
https://github.com/python/cpython.git
synced 2025-08-23 10:16:01 +00:00
Backport code from r65182:
Issue #2620: Overflow checking when allocating or reallocating memory was not always being done properly in some python types and extension modules. PyMem_MALLOC, PyMem_REALLOC, PyMem_NEW and PyMem_RESIZE have all been updated to perform better checks and places in the code that would previously leak memory on the error path when such an allocation failed have been fixed.
This commit is contained in:
parent
c8e4bed1c5
commit
83ac0144fa
6 changed files with 57 additions and 15 deletions
|
@ -349,10 +349,12 @@ update_ufd_array(pollObject *self)
|
|||
{
|
||||
Py_ssize_t i, pos;
|
||||
PyObject *key, *value;
|
||||
struct pollfd *old_ufds = self->ufds;
|
||||
|
||||
self->ufd_len = PyDict_Size(self->dict);
|
||||
PyMem_Resize(self->ufds, struct pollfd, self->ufd_len);
|
||||
PyMem_RESIZE(self->ufds, struct pollfd, self->ufd_len);
|
||||
if (self->ufds == NULL) {
|
||||
self->ufds = old_ufds;
|
||||
PyErr_NoMemory();
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue