diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 5e5f35520ca..7e6bdc8879e 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -5083,8 +5083,10 @@ parse_envlist(PyObject* env, Py_ssize_t *envc_ptr) } envc = 0; keys = PyMapping_Keys(env); + if (!keys) + goto error; vals = PyMapping_Values(env); - if (!keys || !vals) + if (!vals) goto error; if (!PyList_Check(keys) || !PyList_Check(vals)) { PyErr_Format(PyExc_TypeError,