diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-02-16 11:33:32 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-02-16 11:33:32 (GMT) |
commit | 4d0d9829851915e97ae392dd803976be6c95c8d1 (patch) | |
tree | e93666c54592b95dbca422ec66d0896f827957b3 /Python | |
parent | 53fa8b2a4bbb589d3d761284c70f93e0f852df23 (diff) | |
parent | 1a1ff29659f068659dea07f1bd67b8fd4331071c (diff) | |
download | cpython-4d0d9829851915e97ae392dd803976be6c95c8d1.zip cpython-4d0d9829851915e97ae392dd803976be6c95c8d1.tar.gz cpython-4d0d9829851915e97ae392dd803976be6c95c8d1.tar.bz2 |
Issue #23446: Use PyMem_New instead of PyMem_Malloc to avoid possible integer
overflows. Added few missed PyErr_NoMemory().
Diffstat (limited to 'Python')
-rw-r--r-- | Python/peephole.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Python/peephole.c b/Python/peephole.c index 4185462..c56c8fc 100644 --- a/Python/peephole.c +++ b/Python/peephole.c @@ -290,7 +290,7 @@ fold_unaryops_on_constants(unsigned char *codestr, PyObject *consts, PyObject *v static unsigned int * markblocks(unsigned char *code, Py_ssize_t len) { - unsigned int *blocks = (unsigned int *)PyMem_Malloc(len*sizeof(int)); + unsigned int *blocks = PyMem_New(unsigned int, len); int i,j, opcode, blockcnt = 0; if (blocks == NULL) { @@ -398,7 +398,7 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names, goto exitUnchanged; /* Mapping to new jump targets after NOPs are removed */ - addrmap = (int *)PyMem_Malloc(codelen * sizeof(int)); + addrmap = PyMem_New(int, codelen); if (addrmap == NULL) { PyErr_NoMemory(); goto exitError; |