[Python-checkins] cpython: Issue #18408: Fix iobase_readline(), handle PyByteArray_Resize() failure
victor.stinner
python-checkins at python.org
Tue Oct 29 02:44:04 CET 2013
http://hg.python.org/cpython/rev/4749c3ac0654
changeset: 86719:4749c3ac0654
user: Victor Stinner <victor.stinner at gmail.com>
date: Tue Oct 29 02:23:46 2013 +0100
summary:
Issue #18408: Fix iobase_readline(), handle PyByteArray_Resize() failure
files:
Modules/_io/iobase.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/Modules/_io/iobase.c b/Modules/_io/iobase.c
--- 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 @@
}
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 @@
int r;
PyObject *chunks = PyList_New(0);
PyObject *result;
-
+
if (chunks == NULL)
return NULL;
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list