mirror of https://github.com/python/cpython.git
Fix reference leak noted in test_types:
Check for a[:] = a _before_ calling PySequence_Fast on a. release23-maint candidate Reference leak doesn't happen with head of release22-maint.
This commit is contained in:
parent
7d599482f2
commit
b4f49385a3
|
@ -472,15 +472,6 @@ list_ass_slice(PyListObject *a, int ilow, int ihigh, PyObject *v)
|
||||||
n = 0;
|
n = 0;
|
||||||
else {
|
else {
|
||||||
char msg[256];
|
char msg[256];
|
||||||
PyOS_snprintf(msg, sizeof(msg),
|
|
||||||
"must assign sequence"
|
|
||||||
" (not \"%.200s\") to slice",
|
|
||||||
v->ob_type->tp_name);
|
|
||||||
v_as_SF = PySequence_Fast(v, msg);
|
|
||||||
if(v_as_SF == NULL)
|
|
||||||
return -1;
|
|
||||||
n = PySequence_Fast_GET_SIZE(v_as_SF);
|
|
||||||
|
|
||||||
if (a == b) {
|
if (a == b) {
|
||||||
/* Special case "a[i:j] = a" -- copy b first */
|
/* Special case "a[i:j] = a" -- copy b first */
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -491,6 +482,15 @@ list_ass_slice(PyListObject *a, int ilow, int ihigh, PyObject *v)
|
||||||
Py_DECREF(v);
|
Py_DECREF(v);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PyOS_snprintf(msg, sizeof(msg),
|
||||||
|
"must assign sequence"
|
||||||
|
" (not \"%.200s\") to slice",
|
||||||
|
v->ob_type->tp_name);
|
||||||
|
v_as_SF = PySequence_Fast(v, msg);
|
||||||
|
if(v_as_SF == NULL)
|
||||||
|
return -1;
|
||||||
|
n = PySequence_Fast_GET_SIZE(v_as_SF);
|
||||||
}
|
}
|
||||||
if (ilow < 0)
|
if (ilow < 0)
|
||||||
ilow = 0;
|
ilow = 0;
|
||||||
|
|
Loading…
Reference in New Issue