diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c index a1e3cf0deac..dfe95484cfd 100644 --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -100,7 +100,9 @@ list2set(list, set, fd2obj) SOCKET v; /* any intervening fileno() calls could decr this refcnt */ - o = PyList_GetItem(list, i); + if (!(o = PyList_GetItem(list, i))) + return NULL; + Py_INCREF(o); if (PyInt_Check(o)) {