Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix a crash in slice_richcompare(): ensure that the 2 temporary internal
tuples used for the comparison are not tracked by the garbage collector,
since they use borrowed references.
6 changes: 5 additions & 1 deletion Objects/sliceobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -590,13 +590,17 @@ slice_richcompare(PyObject *v, PyObject *w, int op)
}

t1 = PyTuple_New(3);
if (t1 == NULL)
if (t1 == NULL) {
return NULL;
}
PyObject_GC_UnTrack(t1);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it makes sense to add a small comment here explaining why we untrack the tuples?


t2 = PyTuple_New(3);
if (t2 == NULL) {
Py_DECREF(t1);
return NULL;
}
PyObject_GC_UnTrack(t2);

PyTuple_SET_ITEM(t1, 0, ((PySliceObject *)v)->start);
PyTuple_SET_ITEM(t1, 1, ((PySliceObject *)v)->stop);
Expand Down