Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b4f4938

Browse files
author
Michael W. Hudson
committed
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.
1 parent 7d59948 commit b4f4938

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

Objects/listobject.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -472,15 +472,6 @@ list_ass_slice(PyListObject *a, int ilow, int ihigh, PyObject *v)
472472
n = 0;
473473
else {
474474
char msg[256];
475-
PyOS_snprintf(msg, sizeof(msg),
476-
"must assign sequence"
477-
" (not \"%.200s\") to slice",
478-
v->ob_type->tp_name);
479-
v_as_SF = PySequence_Fast(v, msg);
480-
if(v_as_SF == NULL)
481-
return -1;
482-
n = PySequence_Fast_GET_SIZE(v_as_SF);
483-
484475
if (a == b) {
485476
/* Special case "a[i:j] = a" -- copy b first */
486477
int ret;
@@ -491,6 +482,15 @@ list_ass_slice(PyListObject *a, int ilow, int ihigh, PyObject *v)
491482
Py_DECREF(v);
492483
return ret;
493484
}
485+
486+
PyOS_snprintf(msg, sizeof(msg),
487+
"must assign sequence"
488+
" (not \"%.200s\") to slice",
489+
v->ob_type->tp_name);
490+
v_as_SF = PySequence_Fast(v, msg);
491+
if(v_as_SF == NULL)
492+
return -1;
493+
n = PySequence_Fast_GET_SIZE(v_as_SF);
494494
}
495495
if (ilow < 0)
496496
ilow = 0;

0 commit comments

Comments
 (0)