diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-03-25-23-37-26.bpo-36430.sd9xxQ.rst b/Misc/NEWS.d/next/Core and Builtins/2019-03-25-23-37-26.bpo-36430.sd9xxQ.rst new file mode 100644 index 00000000000000..a65ee096efc4a2 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2019-03-25-23-37-26.bpo-36430.sd9xxQ.rst @@ -0,0 +1 @@ +Fix a possible reference leak in :func:`itertools.count`. diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index 1113fb6b76c03d..bff9df608304b6 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -4027,6 +4027,7 @@ count_new(PyTypeObject *type, PyObject *args, PyObject *kwds) lz = (countobject *)type->tp_alloc(type, 0); if (lz == NULL) { Py_XDECREF(long_cnt); + Py_DECREF(long_step); return NULL; } lz->cnt = cnt;