]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[2.7] bpo-36289: Fix a possible reference leak in the io module (GH-12329)
authorstratakis <cstratak@redhat.com>
Thu, 14 Mar 2019 15:35:40 +0000 (16:35 +0100)
committerVictor Stinner <vstinner@redhat.com>
Thu, 14 Mar 2019 15:35:40 +0000 (16:35 +0100)
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 [new file with mode: 0644]
Modules/_io/bufferedio.c

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 (file)
index 0000000..8917bee
--- /dev/null
@@ -0,0 +1 @@
+Fix a possible reference leak in the io module.
index b8c98a4d0d043934ef224760fd5dd70691435d11..d68f7d85b0290238d0fda5bb0fba9e63eea4d322 100644 (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);