]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-145044: avoid calling `Py_DECREF` in `unsafe_object_compare` on immortal objects...
authorBenedikt Johannes <benedikt.johannes.hofer@gmail.com>
Tue, 10 Mar 2026 16:33:56 +0000 (17:33 +0100)
committerGitHub <noreply@github.com>
Tue, 10 Mar 2026 16:33:56 +0000 (22:03 +0530)
Objects/listobject.c

index 62d04ab150a77a0e4e2fcd3f0a90a0b56e4565f7..1fcedd3a28c91b4964c891f15a70e8142a047df9 100644 (file)
@@ -2795,11 +2795,12 @@ unsafe_object_compare(PyObject *v, PyObject *w, MergeState *ms)
 
     if (PyBool_Check(res_obj)) {
         res = (res_obj == Py_True);
+        assert(_Py_IsImmortal(res_obj));
     }
     else {
         res = PyObject_IsTrue(res_obj);
+        Py_DECREF(res_obj);
     }
-    Py_DECREF(res_obj);
 
     /* Note that we can't assert
      *     res == PyObject_RichCompareBool(v, w, Py_LT);