Mercurial > cpython-lru_cache-weakref
diff Python/ceval.c @ 21171:2458cbcc1dd3 legacy-trunk
Fix the final two issues in Armin Rigo's SF bug #488477: apply_slice()
and assign_slice() weren't properly DECREF'ing the temporary slice
object they created. (Shame on me. :-)
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Mon, 03 Dec 2001 19:45:06 +0000 |
| parents | 2dfc600f99ce |
| children | 45e1177424e1 |
line wrap: on
line diff
--- a/Python/ceval.c Mon Dec 03 19:33:25 2001 +0000 +++ b/Python/ceval.c Mon Dec 03 19:45:06 2001 +0000 @@ -3398,8 +3398,11 @@ } else { PyObject *slice = PySlice_New(v, w, NULL); - if (slice != NULL) - return PyObject_GetItem(u, slice); + if (slice != NULL) { + PyObject *res = PyObject_GetItem(u, slice); + Py_DECREF(slice); + return res; + } else return NULL; } @@ -3426,10 +3429,13 @@ else { PyObject *slice = PySlice_New(v, w, NULL); if (slice != NULL) { + int res; if (x != NULL) - return PyObject_SetItem(u, slice, x); + res = PyObject_SetItem(u, slice, x); else - return PyObject_DelItem(u, slice); + res = PyObject_DelItem(u, slice); + Py_DECREF(slice); + return res; } else return -1;
