diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-06-30 18:25:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-30 18:25:50 (GMT) |
commit | e5153d0d404d58e83d802199bea1a8dd0ea5178e (patch) | |
tree | 1e6b1a68fb8c09f5aa203845e6d409c5ebb8fc87 /Modules/_io/stringio.c | |
parent | db7ac30ef52ce35a4ead1bc1b9f0dd5331ed9779 (diff) | |
download | cpython-e5153d0d404d58e83d802199bea1a8dd0ea5178e.zip cpython-e5153d0d404d58e83d802199bea1a8dd0ea5178e.tar.gz cpython-e5153d0d404d58e83d802199bea1a8dd0ea5178e.tar.bz2 |
bpo-25862: Fix several bugs in the _io module. (GH-8026)
They can be exposed when some C API calls fail due to lack of
memory.
* Failed Py_BuildValue() could cause an assertion error in the
following TextIOWrapper.tell().
* input_chunk could be decrefed twice in TextIOWrapper.seek()
after failed Py_BuildValue().
* initvalue could leak in StringIO.__getstate__() after failed
PyDict_Copy().
(cherry picked from commit fdb5a50ef34f7951c3b01eb77b1359725a9ad670)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Modules/_io/stringio.c')
-rw-r--r-- | Modules/_io/stringio.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/_io/stringio.c b/Modules/_io/stringio.c index 8542efd..bf4f892 100644 --- a/Modules/_io/stringio.c +++ b/Modules/_io/stringio.c @@ -870,8 +870,10 @@ stringio_getstate(stringio *self) } else { dict = PyDict_Copy(self->dict); - if (dict == NULL) + if (dict == NULL) { + Py_DECREF(initvalue); return NULL; + } } state = Py_BuildValue("(OOnN)", initvalue, |