From 2dd6e079ae71f3723fbea2582ac080be06a6968f Mon Sep 17 00:00:00 2001 From: stratakis Date: Thu, 14 Mar 2019 16:35:40 +0100 Subject: [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. --- Misc/NEWS.d/next/Library/2019-03-14-15-42-48.bpo-36289.wYKS47.rst | 1 + Modules/_io/bufferedio.c | 1 + 2 files changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2019-03-14-15-42-48.bpo-36289.wYKS47.rst diff --git a/Misc/NEWS.d/next/Library/2019-03-14-15-42-48.bpo-36289.wYKS47.rst b/Misc/NEWS.d/next/Library/2019-03-14-15-42-48.bpo-36289.wYKS47.rst new file mode 100644 index 0000000..8917bee --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-03-14-15-42-48.bpo-36289.wYKS47.rst @@ -0,0 +1 @@ +Fix a possible reference leak in the io module. diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index b8c98a4..d68f7d8 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -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); -- cgit v0.12