mirror of
https://github.com/python/cpython.git
synced 2025-09-29 11:45:57 +00:00
_winconsoleio: Fix memory leak (#2485)
Fix memory leak when _winconsoleio tries to open a non-console file: free the name buffer.
This commit is contained in:
parent
b78fbaaeab
commit
1d56ed5210
1 changed files with 3 additions and 3 deletions
|
@ -317,6 +317,7 @@ _io__WindowsConsoleIO___init___impl(winconsoleio *self, PyObject *nameobj,
|
|||
if (name == NULL)
|
||||
return -1;
|
||||
if (console_type == '\0') {
|
||||
PyMem_Free(name);
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"Cannot open non-console file");
|
||||
return -1;
|
||||
|
@ -428,7 +429,6 @@ error:
|
|||
internal_close(self);
|
||||
|
||||
done:
|
||||
if (name)
|
||||
PyMem_Free(name);
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue