summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-02-16 13:28:22 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2015-02-16 13:28:22 +0200
commit1a1ff29659f068659dea07f1bd67b8fd4331071c (patch)
tree20705986aa369225a02980a11f0a6a66a9eed0ee /Python
parente1efc07a30f4c17723c707ad761bfad538982b0c (diff)
downloadcpython-git-1a1ff29659f068659dea07f1bd67b8fd4331071c.tar.gz
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.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Python/peephole.c b/Python/peephole.c
index 4185462b34..c56c8fcc23 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;