Skip to content

Commit 31b950a

Browse files
authored
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 29adc13)
1 parent ca1b66f commit 31b950a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

Modules/_io/winconsoleio.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ char _PyIO_get_console_type(PyObject *path_or_fd) {
101101

102102
DWORD length;
103103
wchar_t name_buf[MAX_PATH], *pname_buf = name_buf;
104-
104+
105105
length = GetFullPathNameW(decoded_wstr, MAX_PATH, pname_buf, NULL);
106106
if (length > MAX_PATH) {
107107
pname_buf = PyMem_New(wchar_t, length);
@@ -305,8 +305,7 @@ _io__WindowsConsoleIO___init___impl(winconsoleio *self, PyObject *nameobj,
305305
self->fd = fd;
306306

307307
if (fd < 0) {
308-
PyObject *decodedname = Py_None;
309-
Py_INCREF(decodedname);
308+
PyObject *decodedname;
310309

311310
int d = PyUnicode_FSDecoder(nameobj, (void*)&decodedname);
312311
if (!d)

0 commit comments

Comments
 (0)