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

(cherry picked from commit 0523c39e77)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
This commit is contained in:
Miss Islington (bot) 2019-03-26 00:55:35 -07:00 committed by Raymond Hettinger
parent bd96393cda
commit c0dce6aa2c
2 changed files with 2 additions and 0 deletions

View File

@ -0,0 +1 @@
Fix a possible reference leak in :func:`itertools.count`.

View File

@ -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;