Skip to content

Many places have missing PyErr_NoMemory() call after failing memory allocation #151126

@sobolevn

Description

@sobolevn

Crash report

  1. remove_unused_consts in Python/flowgraph.c

When PyMem_Malloc(nconsts * sizeof(Py_ssize_t)); fails, we need to set an exception.

cpython/Python/flowgraph.c

Lines 3267 to 3283 in 29a920e

static int
remove_unused_consts(basicblock *entryblock, PyObject *consts)
{
assert(PyList_CheckExact(consts));
Py_ssize_t nconsts = PyList_GET_SIZE(consts);
if (nconsts == 0) {
return SUCCESS; /* nothing to do */
}
Py_ssize_t *index_map = NULL;
Py_ssize_t *reverse_index_map = NULL;
int err = ERROR;
index_map = PyMem_Malloc(nconsts * sizeof(Py_ssize_t));
if (index_map == NULL) {
goto end;
}

Linked PRs

Metadata

Metadata

Assignees

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)type-crashA hard crash of the interpreter, possibly with a core dump
No fields configured for issues without a type.

Projects

Status
No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions