diff options
author | Victor Stinner <vstinner@python.org> | 2024-09-18 22:11:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-18 22:11:50 (GMT) |
commit | 43cd7aa8cd88624f7211e47b98bc1e8e63e7660f (patch) | |
tree | 2281a676a2346988f7ec70f9884c322ac245212e /Modules | |
parent | ea7fe1fe2e162f2375562467ad834c6224a62daf (diff) | |
download | cpython-43cd7aa8cd88624f7211e47b98bc1e8e63e7660f.zip cpython-43cd7aa8cd88624f7211e47b98bc1e8e63e7660f.tar.gz cpython-43cd7aa8cd88624f7211e47b98bc1e8e63e7660f.tar.bz2 |
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).
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_io/fileio.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c index 865b0e3..8dae465 100644 --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -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(); |