Skip to content

Commit 50f82d0

Browse files
gh-145044: avoid calling Py_DECREF in unsafe_object_compare on immortal objects (#145045)
1 parent 9e08023 commit 50f82d0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Objects/listobject.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2795,11 +2795,12 @@ unsafe_object_compare(PyObject *v, PyObject *w, MergeState *ms)
27952795

27962796
if (PyBool_Check(res_obj)) {
27972797
res = (res_obj == Py_True);
2798+
assert(_Py_IsImmortal(res_obj));
27982799
}
27992800
else {
28002801
res = PyObject_IsTrue(res_obj);
2802+
Py_DECREF(res_obj);
28012803
}
2802-
Py_DECREF(res_obj);
28032804

28042805
/* Note that we can't assert
28052806
* res == PyObject_RichCompareBool(v, w, Py_LT);

0 commit comments

Comments
 (0)