Skip to content

Commit 331d676

Browse files
committed
Fix reference leak
Signed-off-by: Christian Heimes <[email protected]>
1 parent 271e017 commit 331d676

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Modules/gcmodule.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -1997,14 +1997,17 @@ gcmodule_exec(PyObject *module)
19971997
{
19981998
GCState *gcstate = get_gc_state();
19991999

2000-
gcstate->garbage = PyList_New(0);
2000+
/* Initialized by _PyGC_Init() early in interpreter lifecycle */
20012001
if (gcstate->garbage == NULL) {
2002+
PyErr_SetString(PyExc_SystemError,
2003+
"GC garbage bin is not initialized");
20022004
return -1;
20032005
}
20042006
if (PyModule_AddObjectRef(module, "garbage", gcstate->garbage) < 0) {
20052007
return -1;
20062008
}
20072009

2010+
assert(gcstate->callbacks == NULL);
20082011
gcstate->callbacks = PyList_New(0);
20092012
if (gcstate->callbacks == NULL) {
20102013
return -1;

0 commit comments

Comments
 (0)