diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-06-08 21:13:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-08 21:13:12 (GMT) |
commit | 31b950ab86f5c99a18c16dbf1900b854b94e0659 (patch) | |
tree | 952f36b6ca2216ad2f5357a139ba04a49422ac31 /Modules/_io/winconsoleio.c | |
parent | ca1b66fd059758bbd6e2cc62c8f2adecefe8f942 (diff) | |
download | cpython-31b950ab86f5c99a18c16dbf1900b854b94e0659.zip cpython-31b950ab86f5c99a18c16dbf1900b854b94e0659.tar.gz cpython-31b950ab86f5c99a18c16dbf1900b854b94e0659.tar.bz2 |
bpo-30601: Fix a refleak in WindowsConsoleIO (#2003) (#2008)
Fix a reference leak in _io._WindowsConsoleIO: PyUnicode_FSDecoder()
always initialize decodedname when it succeed and it doesn't clear
input decodedname object.
(cherry picked from commit 29adc13bd797d9c9e7fcb893a7c49ce7f7ad388c)
Diffstat (limited to 'Modules/_io/winconsoleio.c')
-rw-r--r-- | Modules/_io/winconsoleio.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/Modules/_io/winconsoleio.c b/Modules/_io/winconsoleio.c index cbe2142..94dfe3e 100644 --- a/Modules/_io/winconsoleio.c +++ b/Modules/_io/winconsoleio.c @@ -101,7 +101,7 @@ char _PyIO_get_console_type(PyObject *path_or_fd) { DWORD length; wchar_t name_buf[MAX_PATH], *pname_buf = name_buf; - + length = GetFullPathNameW(decoded_wstr, MAX_PATH, pname_buf, NULL); if (length > MAX_PATH) { pname_buf = PyMem_New(wchar_t, length); @@ -305,8 +305,7 @@ _io__WindowsConsoleIO___init___impl(winconsoleio *self, PyObject *nameobj, self->fd = fd; if (fd < 0) { - PyObject *decodedname = Py_None; - Py_INCREF(decodedname); + PyObject *decodedname; int d = PyUnicode_FSDecoder(nameobj, (void*)&decodedname); if (!d) |