mirror of
https://github.com/python/cpython.git
synced 2025-09-30 20:31:52 +00:00
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 29adc13bd7
)
This commit is contained in:
parent
ca1b66fd05
commit
31b950ab86
1 changed files with 2 additions and 3 deletions
|
@ -101,7 +101,7 @@ char _PyIO_get_console_type(PyObject *path_or_fd) {
|
||||||
|
|
||||||
DWORD length;
|
DWORD length;
|
||||||
wchar_t name_buf[MAX_PATH], *pname_buf = name_buf;
|
wchar_t name_buf[MAX_PATH], *pname_buf = name_buf;
|
||||||
|
|
||||||
length = GetFullPathNameW(decoded_wstr, MAX_PATH, pname_buf, NULL);
|
length = GetFullPathNameW(decoded_wstr, MAX_PATH, pname_buf, NULL);
|
||||||
if (length > MAX_PATH) {
|
if (length > MAX_PATH) {
|
||||||
pname_buf = PyMem_New(wchar_t, length);
|
pname_buf = PyMem_New(wchar_t, length);
|
||||||
|
@ -305,8 +305,7 @@ _io__WindowsConsoleIO___init___impl(winconsoleio *self, PyObject *nameobj,
|
||||||
self->fd = fd;
|
self->fd = fd;
|
||||||
|
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
PyObject *decodedname = Py_None;
|
PyObject *decodedname;
|
||||||
Py_INCREF(decodedname);
|
|
||||||
|
|
||||||
int d = PyUnicode_FSDecoder(nameobj, (void*)&decodedname);
|
int d = PyUnicode_FSDecoder(nameobj, (void*)&decodedname);
|
||||||
if (!d)
|
if (!d)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue