mirror of
https://github.com/python/cpython.git
synced 2026-06-28 03:41:13 +00:00
[3.15] gh-151126: Fix missing PyErr_NoMemory() in remove_unused_consts (GH-151127) (#151134)
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:
parent
83e26a43a7
commit
8a2bf2a072
2 changed files with 5 additions and 0 deletions
|
|
@ -0,0 +1,3 @@
|
|||
Fix a crash, when there's no memory left on a device,
|
||||
which happened in code compilation.
|
||||
Now it raises a proper :exc:`MemoryError`.
|
||||
|
|
@ -3273,6 +3273,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++) {
|
||||
|
|
@ -3325,6 +3326,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++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue