Issue 29874: Need a look for return value checking [selectmodule.c] (original) (raw)

In file selectmodule.c

our static code scanner has reported the following case, function set2list is liable to return NULL (if PyTuple_New failed), would any chance the NULL pointer be dereferenced (Py_DECREF(fdlist) after set2list) or it would just raise python exception to handle PyTuple_New error ?

static PyObject * select_select(PyObject *self, PyObject args) { ...... if (n < 0) { PyErr_SetFromErrno(SelectError); } #endif else { / any of these three calls can raise an exception. it's more convenient to test for this after all three calls... but is that acceptable? */ ifdlist = set2list(&ifdset, rfd2obj); // || <===== ofdlist = set2list(&ofdset, wfd2obj); // || efdlist = set2list(&efdset, efd2obj); // || if (PyErr_Occurred()) ret = NULL; else ret = PyTuple_Pack(3, ifdlist, ofdlist, efdlist);

    Py_DECREF(ifdlist);
    Py_DECREF(ofdlist);
    Py_DECREF(efdlist);