summaryrefslogtreecommitdiffstats
path: root/Modules/_io
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-10-29 01:23:46 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-10-29 01:23:46 (GMT)
commitcc024d18207f9967c707186eec77731a6c1eea35 (patch)
tree202a479565b076dc91621156f2066a4b219ed531 /Modules/_io
parentaf8b7e823360f94714f8eded4a27572914851c7d (diff)
downloadcpython-cc024d18207f9967c707186eec77731a6c1eea35.zip
cpython-cc024d18207f9967c707186eec77731a6c1eea35.tar.gz
cpython-cc024d18207f9967c707186eec77731a6c1eea35.tar.bz2
Issue #18408: Fix iobase_readline(), handle PyByteArray_Resize() failure
Diffstat (limited to 'Modules/_io')
-rw-r--r--Modules/_io/iobase.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/Modules/_io/iobase.c b/Modules/_io/iobase.c
index ae188dd..b58687e 100644
--- a/Modules/_io/iobase.c
+++ b/Modules/_io/iobase.c
@@ -1,9 +1,9 @@
/*
An implementation of the I/O abstract base classes hierarchy
as defined by PEP 3116 - "New I/O"
-
+
Classes defined here: IOBase, RawIOBase.
-
+
Written by Amaury Forgeot d'Arc and Antoine Pitrou
*/
@@ -19,7 +19,7 @@
typedef struct {
PyObject_HEAD
-
+
PyObject *dict;
PyObject *weakreflist;
} iobase;
@@ -530,7 +530,10 @@ iobase_readline(PyObject *self, PyObject *args)
}
old_size = PyByteArray_GET_SIZE(buffer);
- PyByteArray_Resize(buffer, old_size + PyBytes_GET_SIZE(b));
+ if (PyByteArray_Resize(buffer, old_size + PyBytes_GET_SIZE(b)) < 0) {
+ Py_DECREF(b);
+ goto fail;
+ }
memcpy(PyByteArray_AS_STRING(buffer) + old_size,
PyBytes_AS_STRING(b), PyBytes_GET_SIZE(b));
@@ -835,7 +838,7 @@ rawiobase_readall(PyObject *self, PyObject *args)
int r;
PyObject *chunks = PyList_New(0);
PyObject *result;
-
+
if (chunks == NULL)
return NULL;