https://github.com/python/cpython/commit/43cd7aa8cd88624f7211e47b98bc1e8e63e7660f
commit: 43cd7aa8cd88624f7211e47b98bc1e8e63e7660f
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2024-09-19T00:11:50+02:00
summary:
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).
files:
M Modules/_io/fileio.c
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
index 865b0e3634f3b4..8dae465fd20f8b 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();
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]