gh-146527: Fix memory leak in _PyGC_Fini() (GH-150969)
Free generation_stats allocated by _PyGC_Init().
Fix Python/gc.c: Python/gc_free_threading.c was already fixed.
(cherry picked from commit
0036565e81b9580d645862bcc6249e2ae4f1fd03)
Co-authored-by: Victor Stinner <vstinner@python.org>
GCState *gcstate = &interp->gc;
Py_CLEAR(gcstate->garbage);
Py_CLEAR(gcstate->callbacks);
+ PyMem_RawFree(gcstate->generation_stats);
+ gcstate->generation_stats = NULL;
/* Prevent a subtle bug that affects sub-interpreters that use basic
* single-phase init extensions (m_size == -1). Those extensions cause objects