From 4e8b6568891c1613712957d68e1a9b6da499917b Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Mon, 25 Mar 2019 23:37:47 -0600 Subject: [PATCH] bpo-36430: Fix a possible reference leak in itertools.count() --- .../Core and Builtins/2019-03-25-23-37-26.bpo-36430.sd9xxQ.rst | 1 + Modules/itertoolsmodule.c | 1 + 2 files changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2019-03-25-23-37-26.bpo-36430.sd9xxQ.rst 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 536f7fa6253a21..103029d251e0da 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -4089,6 +4089,7 @@ itertools_count_impl(PyTypeObject *type, PyObject *long_cnt, lz = (countobject *)type->tp_alloc(type, 0); if (lz == NULL) { Py_XDECREF(long_cnt); + Py_DECREF(long_step); return NULL; } lz->cnt = cnt;