gh-105375: Improve posix error handling (#105592)
Fix a bug where an IndexError could end up being overwritten.
This commit is contained in:
parent
eede1d2f48
commit
f668f73bc8
@ -0,0 +1,2 @@
|
|||||||
|
Fix a bug in the :mod:`posix` module where an exception could be
|
||||||
|
overwritten.
|
@ -6414,7 +6414,7 @@ parse_envlist(PyObject* env, Py_ssize_t *envc_ptr)
|
|||||||
{
|
{
|
||||||
Py_ssize_t i, pos, envc;
|
Py_ssize_t i, pos, envc;
|
||||||
PyObject *keys=NULL, *vals=NULL;
|
PyObject *keys=NULL, *vals=NULL;
|
||||||
PyObject *key, *val, *key2, *val2, *keyval;
|
PyObject *key2, *val2, *keyval;
|
||||||
EXECV_CHAR **envlist;
|
EXECV_CHAR **envlist;
|
||||||
|
|
||||||
i = PyMapping_Size(env);
|
i = PyMapping_Size(env);
|
||||||
@ -6439,10 +6439,14 @@ parse_envlist(PyObject* env, Py_ssize_t *envc_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (pos = 0; pos < i; pos++) {
|
for (pos = 0; pos < i; pos++) {
|
||||||
key = PyList_GetItem(keys, pos);
|
PyObject *key = PyList_GetItem(keys, pos); // Borrowed ref.
|
||||||
val = PyList_GetItem(vals, pos);
|
if (key == NULL) {
|
||||||
if (!key || !val)
|
|
||||||
goto error;
|
goto error;
|
||||||
|
}
|
||||||
|
PyObject *val = PyList_GetItem(vals, pos); // Borrowed ref.
|
||||||
|
if (val == NULL) {
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(HAVE_WEXECV) || defined(HAVE_WSPAWNV)
|
#if defined(HAVE_WEXECV) || defined(HAVE_WSPAWNV)
|
||||||
if (!PyUnicode_FSDecoder(key, &key2))
|
if (!PyUnicode_FSDecoder(key, &key2))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user