cpython: 3f25a7dd8346 (original) (raw)
Mercurial > cpython
changeset 84717:3f25a7dd8346
Issue #18408: Fix list_ass_slice(), handle list_resize() failure I tested the patch manually by injecting a fault using gdb: list items are correctly restored on failure. [#18408]
Victor Stinner victor.stinner@gmail.com | |
---|---|
date | Fri, 19 Jul 2013 23:06:21 +0200 |
parents | 1ff5e7505696 |
children | eaa77b72bff4 |
files | Objects/listobject.c |
diffstat | 1 files changed, 8 insertions(+), 3 deletions(-)[+] [-] Objects/listobject.c 11 |
line wrap: on
line diff
--- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -644,9 +644,14 @@ list_ass_slice(PyListObject a, Py_ssize memcpy(recycle, &item[ilow], s); if (d < 0) { / Delete -d items */
memmove(&item[ihigh+d], &item[ihigh],[](#l1.7)
(Py_SIZE(a) - ihigh)*sizeof(PyObject *));[](#l1.8)
list_resize(a, Py_SIZE(a) + d);[](#l1.9)
Py_ssize_t tail;[](#l1.10)
tail = (Py_SIZE(a) - ihigh) * sizeof(PyObject *);[](#l1.11)
memmove(&item[ihigh+d], &item[ihigh], tail);[](#l1.12)
if (list_resize(a, Py_SIZE(a) + d) < 0) {[](#l1.13)
memmove(&item[ihigh], &item[ihigh+d], tail);[](#l1.14)
memcpy(&item[ilow], recycle, s);[](#l1.15)
goto Error;[](#l1.16)
} else if (d > 0) { /* Insert d items */}[](#l1.17) item = a->ob_item;[](#l1.18)