Skip to content

Commit 0036565

Browse files
authored
gh-146527: Fix memory leak in _PyGC_Fini() (#150969)
Free generation_stats allocated by _PyGC_Init(). Fix Python/gc.c: Python/gc_free_threading.c was already fixed.
1 parent c195a04 commit 0036565

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

Python/gc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,6 +1876,8 @@ _PyGC_Fini(PyInterpreterState *interp)
18761876
GCState *gcstate = &interp->gc;
18771877
Py_CLEAR(gcstate->garbage);
18781878
Py_CLEAR(gcstate->callbacks);
1879+
PyMem_RawFree(gcstate->generation_stats);
1880+
gcstate->generation_stats = NULL;
18791881

18801882
/* Prevent a subtle bug that affects sub-interpreters that use basic
18811883
* single-phase init extensions (m_size == -1). Those extensions cause objects

0 commit comments

Comments
 (0)