Fix memory leak when _winconsoleio tries to open a non-console file:
free the name buffer.
if (name == NULL)
return -1;
if (console_type == '\0') {
+ PyMem_Free(name);
PyErr_SetString(PyExc_ValueError,
"Cannot open non-console file");
return -1;
PyErr_SetString(PyExc_ValueError,
"Cannot open non-console file");
goto error;
- }
+ }
if (self->writable && console_type != 'w') {
PyErr_SetString(PyExc_ValueError,
"Cannot open console input buffer for writing");
internal_close(self);
done:
- if (name)
- PyMem_Free(name);
+ PyMem_Free(name);
return ret;
}