Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Tighten scope of relevant short lived variables
  • Loading branch information
arhadthedev committed Jul 27, 2022
commit 6a236e52fdbecb011d00131210743c617262d5c4
6 changes: 2 additions & 4 deletions Modules/_posixsubprocess.c
Original file line number Diff line number Diff line change
Expand Up @@ -905,9 +905,6 @@ subprocess_fork_exec(PyObject *module, PyObject *args)

if (groups_list != Py_None) {
#ifdef HAVE_SETGROUPS
Py_ssize_t i;
gid_t gid;

if (!PyList_Check(groups_list)) {
PyErr_SetString(PyExc_TypeError,
"setgroups argument must be a list");
Expand All @@ -933,7 +930,7 @@ subprocess_fork_exec(PyObject *module, PyObject *args)
}
}

for (i = 0; i < num_groups; i++) {
for (Py_ssize_t i = 0; i < num_groups; i++) {
PyObject *elem;
elem = PySequence_GetItem(groups_list, i);
if (!elem)
Expand All @@ -944,6 +941,7 @@ subprocess_fork_exec(PyObject *module, PyObject *args)
Py_DECREF(elem);
goto cleanup;
} else {
gid_t gid;
if (!_Py_Gid_Converter(elem, &gid)) {
Py_DECREF(elem);
PyErr_SetString(PyExc_ValueError, "invalid group id");
Expand Down