mirror of
https://github.com/python/cpython.git
synced 2025-08-27 12:16:04 +00:00
Issue #23446: Use PyMem_New instead of PyMem_Malloc to avoid possible integer
overflows. Added few missed PyErr_NoMemory().
This commit is contained in:
parent
e1efc07a30
commit
1a1ff29659
15 changed files with 50 additions and 52 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue