diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 89fe82c7c39..9eb725f062b 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -5931,6 +5931,7 @@ slot_sq_length(PyObject *self) assert(PyLong_Check(res)); if (Py_SIZE(res) < 0) { + Py_DECREF(res); PyErr_SetString(PyExc_ValueError, "__len__() should return >= 0"); return -1;