diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 5659c71ce8e..30a925c3413 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -12941,9 +12941,9 @@ unicode_endswith(PyObject *self, return NULL; } result = tailmatch(self, substring, start, end, +1); + Py_DECREF(substring); if (result == -1) return NULL; - Py_DECREF(substring); return PyBool_FromLong(result); }