[Python-checkins] bpo-36430: Fix a possible reference leak in itertools.count(). (GH-12551) (GH-12554)

Raymond Hettinger webhook-mailer at python.org
Tue Mar 26 03:55:42 EDT 2019


https://github.com/python/cpython/commit/c0dce6aa2ce1ff408170bb8de2ebde3bfd8aa6cf
commit: c0dce6aa2ce1ff408170bb8de2ebde3bfd8aa6cf
branch: 2.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Raymond Hettinger <rhettinger at users.noreply.github.com>
date: 2019-03-26T00:55:35-07:00
summary:

bpo-36430: Fix a possible reference leak in itertools.count(). (GH-12551) (GH-12554)

(cherry picked from commit 0523c39e7720b82b38ad793d3f1a5681adcdf873)

Co-authored-by: Zackery Spytz <zspytz at gmail.com>

files:
A Misc/NEWS.d/next/Core and Builtins/2019-03-25-23-37-26.bpo-36430.sd9xxQ.rst
M Modules/itertoolsmodule.c

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 000000000000..a65ee096efc4
--- /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 47db7affb059..04076fd08709 100644
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -3321,6 +3321,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;



More information about the Python-checkins mailing list