summaryrefslogtreecommitdiffstats
path: root/Modules/cStringIO.c
diff options
context:
space:
mode:
authorMichael W. Hudson <mwh@python.net>2005-09-22 09:19:01 (GMT)
committerMichael W. Hudson <mwh@python.net>2005-09-22 09:19:01 (GMT)
commit10402a306f613b37c96b51771e7ad0e1cf60a3a4 (patch)
tree6c85e5c1a3d9cffc956aad4b7730ca86c88e008a /Modules/cStringIO.c
parent19e11c86a72f6da18bd07b822eabe2f38dd6d6c4 (diff)
downloadcpython-10402a306f613b37c96b51771e7ad0e1cf60a3a4.zip
cpython-10402a306f613b37c96b51771e7ad0e1cf60a3a4.tar.gz
cpython-10402a306f613b37c96b51771e7ad0e1cf60a3a4.tar.bz2
Patches #1298449 and #1298499: Add some missing checks for error
returns in cStringIO.c. Thanks to Andrew Bennetts. This must be a backport candidate.
Diffstat (limited to 'Modules/cStringIO.c')
-rw-r--r--Modules/cStringIO.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/Modules/cStringIO.c b/Modules/cStringIO.c
index b7333fd..9ed77d8 100644
--- a/Modules/cStringIO.c
+++ b/Modules/cStringIO.c
@@ -241,7 +241,10 @@ IO_readlines(IOobject *self, PyObject *args) {
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,13 +443,18 @@ O_writelines(Oobject *self, PyObject *args) {
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[] = {
/* Common methods: */
{"flush", (PyCFunction)IO_flush, METH_NOARGS, IO_flush__doc__},