diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2008-07-28 05:06:20 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2008-07-28 05:06:20 (GMT) |
commit | 83ac0144fa3041556aa4f3952ebd979e0189a19c (patch) | |
tree | 6ea0926c622f76b3eb8542cad72ffde6aaabc551 /Modules/selectmodule.c | |
parent | c8e4bed1c5a11b0447feb38d0870af056a71ad2c (diff) | |
download | cpython-83ac0144fa3041556aa4f3952ebd979e0189a19c.zip cpython-83ac0144fa3041556aa4f3952ebd979e0189a19c.tar.gz cpython-83ac0144fa3041556aa4f3952ebd979e0189a19c.tar.bz2 |
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.
Diffstat (limited to 'Modules/selectmodule.c')
-rw-r--r-- | Modules/selectmodule.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c index 9eaae84..4deab6f 100644 --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -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; } |