[2.7] bpo-36289: Fix a possible reference leak in the io module (GH-12329)

Fix a reference leak in _bufferedreader_read_all():
_io.BufferedIOMixin.read() leaks a reference on 'data'
when it reads the whole file content but flush() fails.
This commit is contained in:
stratakis 2019-03-14 16:35:40 +01:00 committed by Victor Stinner
parent fb3336acfd
commit 2dd6e079ae
2 changed files with 2 additions and 0 deletions

View File

@ -0,0 +1 @@
Fix a possible reference leak in the io module.

View File

@ -1363,6 +1363,7 @@ _bufferedreader_read_all(buffered *self)
res = buffered_flush_and_rewind_unlocked(self);
if (res == NULL) {
Py_DECREF(chunks);
Py_XDECREF(data);
return NULL;
}
Py_CLEAR(res);