Skip to content

Commit 26c6425

Browse files
authored
Add a missing NULL check
1 parent fdfadf0 commit 26c6425

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Python/pylifecycle.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,9 +1546,12 @@ static PyObject*
15461546
finalize_remove_modules(PyObject *modules, int verbose)
15471547
{
15481548
PyObject *weaklist = PyList_New(0);
1549-
PyObject *weak_ext = PyList_New(0); // for extending the weaklist
1550-
if (weak_ext == NULL) {
1551-
Py_CLEAR(weaklist);
1549+
PyObject *weak_ext = NULL; // for extending the weaklist
1550+
if (weaklist != NULL) {
1551+
weak_ext = PyList_New(0);
1552+
if (weak_ext == NULL) {
1553+
Py_CLEAR(weaklist);
1554+
}
15521555
}
15531556
if (weaklist == NULL) {
15541557
PyErr_FormatUnraisable("Exception ignored while removing modules");

0 commit comments

Comments
 (0)