10000 bpo-30602: Fix lastarg in os.spawnve() (#2287) · python/cpython@c8d6ab2 · GitHub
[go: up one dir, main page]

Skip to content

Commit c8d6ab2

Browse files
authored
bpo-30602: Fix lastarg in os.spawnve() (#2287)
Fix a regression introduced by myself in the commit 526b226.
1 parent 87c6555 commit c8d6ab2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Modules/posixmodule.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5223,7 +5223,7 @@ os_spawnve_impl(PyObject *module, int mode, path_t *path, PyObject *argv,
52235223
Py_ssize_t argc, i, envc;
52245224
intptr_t spawnval;
52255225
PyObject *(*getitem)(PyObject *, Py_ssize_t);
5226-
Py_ssize_t lastarg = -1;
5226+
Py_ssize_t lastarg = 0;
52275227

52285228
/* spawnve has four arguments: (mode, path, argv, env), where
52295229
argv is a list or tuple of strings and env is a dictionary
@@ -5266,7 +5266,7 @@ os_spawnve_impl(PyObject *module, int mode, path_t *path, PyObject *argv,
52665266
goto fail_1;
52675267
}
52685268
if (i == 0 && !argvlist[0][0]) {
5269-
lastarg = i;
5269+
lastarg = i + 1;
52705270
PyErr_SetString(
52715271
PyExc_ValueError,
52725272
"spawnv() arg 2 first element cannot be empty");
@@ -5302,7 +5302,7 @@ os_spawnve_impl(PyObject *module, int mode, path_t *path, PyObject *argv,
53025302
PyMem_DEL(envlist[envc]);
53035303
PyMem_DEL(envlist);
53045304
fail_1:
5305-
free_string_array(argvlist, lastarg + 1);
5305+
< 4827 span class="pl-en">free_string_array(argvlist, lastarg);
53065306
fail_0:
53075307
return res;
53085308
}

0 commit comments

Comments
 (0)
0