Skip to content

Commit 263bdb2

Browse files
authored
Add non-NULL check
1 parent e33f704 commit 263bdb2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Python/pylifecycle.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,10 +1621,12 @@ finalize_remove_modules(PyObject *modules, int verbose)
16211621
}
16221622
}
16231623

1624-
if (PyList_Extend(weaklist, weak_ext) < 0) {
1625-
PyErr_FormatUnraisable("Exception ignored while removing modules");
1624+
if (weaklist != NULL) {
1625+
if (PyList_Extend(weaklist, weak_ext) < 0) {
1626+
PyErr_FormatUnraisable("Exception ignored while removing modules");
1627+
}
1628+
Py_DECREF(weak_ext);
16261629
}
1627-
Py_DECREF(weak_ext);
16281630

16291631
#undef CLEAR_MODULE
16301632
#undef STORE_MODULE_WEAKREF

0 commit comments

Comments
 (0)