mirror of https://github.com/python/cpython
gh-120754: Fix memory leak in FileIO.__init__() (#124225)
Free 'self->stat_atopen' before assigning it, since io.FileIO.__init__() can be called multiple times manually (especially by test_io).
This commit is contained in:
parent
ea7fe1fe2e
commit
43cd7aa8cd
|
@ -457,6 +457,7 @@ _io_FileIO___init___impl(fileio *self, PyObject *nameobj, const char *mode,
|
|||
#endif
|
||||
}
|
||||
|
||||
PyMem_Free(self->stat_atopen);
|
||||
self->stat_atopen = PyMem_New(struct _Py_stat_struct, 1);
|
||||
if (self->stat_atopen == NULL) {
|
||||
PyErr_NoMemory();
|
||||
|
|
Loading…
Reference in New Issue