Mercurial > cpython-lru_cache-weakref
diff Modules/cStringIO.c @ 35642:e0a9f66b7014 2.4
Backport (with Anthony's blessing (in fact he reminded me to do it :)):
Patches #1298449 and #1298499: Add some missing checks for error
returns in cStringIO.c. Thanks to Andrew Bennetts.
This must be a backport candidate.
| author | Michael W. Hudson <mwh@python.net> |
|---|---|
| date | Mon, 26 Sep 2005 13:15:34 +0000 |
| parents | db1bafa9b656 |
| children | accfb156f9cc |
line wrap: on
line diff
--- a/Modules/cStringIO.c Sun Sep 25 06:16:28 2005 +0000 +++ b/Modules/cStringIO.c Mon Sep 26 13:15:34 2005 +0000 @@ -241,7 +241,10 @@ line = PyString_FromStringAndSize (output, n); if (!line) goto err; - PyList_Append (result, line); + if (PyList_Append (result, line) == -1) { + Py_DECREF (line); + goto err; + } Py_DECREF (line); length += n; if (hint > 0 && length >= hint) @@ -440,11 +443,17 @@ Py_DECREF(it); Py_DECREF(s); return NULL; - } - Py_DECREF(s); - } - Py_DECREF(it); - Py_RETURN_NONE; + } + Py_DECREF(s); + } + + Py_DECREF(it); + + /* See if PyIter_Next failed */ + if (PyErr_Occurred()) + return NULL; + + Py_RETURN_NONE; } static struct PyMethodDef O_methods[] = {
