diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-02-16 21:28:29 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-02-16 21:28:29 (GMT) |
commit | 25e26a02f4bd5500cf29e3b298ddc2447e07abd1 (patch) | |
tree | d668c4e87e52a75e1394b4a764a7a27c9c378186 /Modules | |
parent | 2c9abd591904040ca06767e31e11c25e0a9937fd (diff) | |
download | cpython-25e26a02f4bd5500cf29e3b298ddc2447e07abd1.zip cpython-25e26a02f4bd5500cf29e3b298ddc2447e07abd1.tar.gz cpython-25e26a02f4bd5500cf29e3b298ddc2447e07abd1.tar.bz2 |
Merged revisions 69688,69690 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r69688 | benjamin.peterson | 2009-02-16 15:07:52 -0600 (Mon, 16 Feb 2009) | 1 line
fix compiler warnings
........
r69690 | benjamin.peterson | 2009-02-16 15:23:04 -0600 (Mon, 16 Feb 2009) | 1 line
PyList_Append() can fail
........
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/itertoolsmodule.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index 3cec421..3eb760b 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -745,8 +745,10 @@ cycle_next(cycleobject *lz) while (1) { item = PyIter_Next(lz->it); if (item != NULL) { - if (!lz->firstpass) - PyList_Append(lz->saved, item); + if (!lz->firstpass && PyList_Append(lz->saved, item)) { + Py_DECREF(item); + return NULL; + } return item; } if (PyErr_Occurred()) { @@ -2922,8 +2924,8 @@ count_new(PyTypeObject *type, PyObject *args, PyObject *kwds) kwlist, &long_cnt, &long_step)) return NULL; - if (long_cnt != NULL && !PyNumber_Check(long_cnt) || - long_step != NULL && !PyNumber_Check(long_step)) { + if ((long_cnt != NULL && !PyNumber_Check(long_cnt)) || + (long_step != NULL && !PyNumber_Check(long_step))) { PyErr_SetString(PyExc_TypeError, "a number is required"); return NULL; } @@ -2950,8 +2952,8 @@ count_new(PyTypeObject *type, PyObject *args, PyObject *kwds) } else long_cnt = NULL; } - assert(cnt != PY_SSIZE_T_MAX && long_cnt == NULL || - cnt == PY_SSIZE_T_MAX && long_cnt != NULL); + assert((cnt != PY_SSIZE_T_MAX && long_cnt == NULL) || + (cnt == PY_SSIZE_T_MAX && long_cnt != NULL)); /* create countobject structure */ lz = (countobject *)type->tp_alloc(type, 0); @@ -2975,6 +2977,7 @@ count_dealloc(countobject *lz) Py_TYPE(lz)->tp_free(lz); } +static int count_traverse(countobject *lz, visitproc visit, void *arg) { Py_VISIT(lz->long_cnt); @@ -2985,7 +2988,6 @@ count_traverse(countobject *lz, visitproc visit, void *arg) static PyObject * count_nextlong(countobject *lz) { - static PyObject *one = NULL; PyObject *long_cnt; PyObject *stepped_up; |