[3.13] gh-151126: Fix missing PyErr_NoMemory() in remove_unused_consts (GH-151127) (#151136)

gh-151126: Fix missing `PyErr_NoMemory()` in `remove_unused_consts` (GH-151127)
(cherry picked from commit 3186547c1e)

Co-authored-by: sobolevn <mail@sobolevn.me>
This commit is contained in:
Miss Islington (bot) 2026-06-09 12:27:34 +02:00 committed by GitHub
parent c51354e062
commit 140af0fd14
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 0 deletions

View file

@ -2040,6 +2040,7 @@ remove_unused_consts(basicblock *entryblock, PyObject *consts)
index_map = PyMem_Malloc(nconsts * sizeof(Py_ssize_t));
if (index_map == NULL) {
PyErr_NoMemory();
goto end;
}
for (Py_ssize_t i = 1; i < nconsts; i++) {
@ -2097,6 +2098,7 @@ remove_unused_consts(basicblock *entryblock, PyObject *consts)
/* adjust const indices in the bytecode */
reverse_index_map = PyMem_Malloc(nconsts * sizeof(Py_ssize_t));
if (reverse_index_map == NULL) {
PyErr_NoMemory();
goto end;
}
for (Py_ssize_t i = 0; i < nconsts; i++) {