summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-12-03 19:45:06 (GMT)
committerGuido van Rossum <guido@python.org>2001-12-03 19:45:06 (GMT)
commit354797ccade3c7fa463c415e3d90fad907e4be5d (patch)
tree4d9f27f2cb27bc33fb19dd9749eb8c42c66dc743
parentbb8f59a37148eb81ef1a1a26a6fb6e1e03583d12 (diff)
downloadcpython-354797ccade3c7fa463c415e3d90fad907e4be5d.zip
cpython-354797ccade3c7fa463c415e3d90fad907e4be5d.tar.gz
cpython-354797ccade3c7fa463c415e3d90fad907e4be5d.tar.bz2
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. :-)
-rw-r--r--Python/ceval.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index b41ef5a..5358517 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -3398,8 +3398,11 @@ apply_slice(PyObject *u, PyObject *v, PyObject *w) /* return u[v:w] */
}
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 @@ assign_slice(PyObject *u, PyObject *v, PyObject *w, PyObject *x)
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;