mirror of
https://github.com/python/cpython.git
synced 2025-10-18 12:48:57 +00:00
Close #19578: Fix list_ass_subscript(), handle list_resize() failure
Notify the caller of the failure (MemoryError exception).
This commit is contained in:
parent
a282825bf6
commit
35f2803a24
1 changed files with 3 additions and 2 deletions
|
@ -2483,6 +2483,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
|
||||||
PyObject **garbage;
|
PyObject **garbage;
|
||||||
size_t cur;
|
size_t cur;
|
||||||
Py_ssize_t i;
|
Py_ssize_t i;
|
||||||
|
int res;
|
||||||
|
|
||||||
if (slicelength <= 0)
|
if (slicelength <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2533,14 +2534,14 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_SIZE(self) -= slicelength;
|
Py_SIZE(self) -= slicelength;
|
||||||
list_resize(self, Py_SIZE(self));
|
res = list_resize(self, Py_SIZE(self));
|
||||||
|
|
||||||
for (i = 0; i < slicelength; i++) {
|
for (i = 0; i < slicelength; i++) {
|
||||||
Py_DECREF(garbage[i]);
|
Py_DECREF(garbage[i]);
|
||||||
}
|
}
|
||||||
PyMem_FREE(garbage);
|
PyMem_FREE(garbage);
|
||||||
|
|
||||||
return 0;
|
return res;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* assign slice */
|
/* assign slice */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue