Kaydet (Commit) 354797cc authored tarafından Guido van Rossum's avatar Guido van Rossum

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. :-)
üst bb8f59a3
...@@ -3398,8 +3398,11 @@ apply_slice(PyObject *u, PyObject *v, PyObject *w) /* return u[v:w] */ ...@@ -3398,8 +3398,11 @@ apply_slice(PyObject *u, PyObject *v, PyObject *w) /* return u[v:w] */
} }
else { else {
PyObject *slice = PySlice_New(v, w, NULL); PyObject *slice = PySlice_New(v, w, NULL);
if (slice != NULL) if (slice != NULL) {
return PyObject_GetItem(u, slice); PyObject *res = PyObject_GetItem(u, slice);
Py_DECREF(slice);
return res;
}
else else
return NULL; return NULL;
} }
...@@ -3426,10 +3429,13 @@ assign_slice(PyObject *u, PyObject *v, PyObject *w, PyObject *x) ...@@ -3426,10 +3429,13 @@ assign_slice(PyObject *u, PyObject *v, PyObject *w, PyObject *x)
else { else {
PyObject *slice = PySlice_New(v, w, NULL); PyObject *slice = PySlice_New(v, w, NULL);
if (slice != NULL) { if (slice != NULL) {
int res;
if (x != NULL) if (x != NULL)
return PyObject_SetItem(u, slice, x); res = PyObject_SetItem(u, slice, x);
else else
return PyObject_DelItem(u, slice); res = PyObject_DelItem(u, slice);
Py_DECREF(slice);
return res;
} }
else else
return -1; return -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment