summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-06-14 12:26:21 (GMT)
committerGitHub <noreply@github.com>2017-06-14 12:26:21 (GMT)
commit526b22657cb18fe79118c2ea68511aca09430c2c (patch)
treeff0da0de5bc2623e134ebe4b871d230b3266c804 /Modules/posixmodule.c
parent3402f7268897db15053866e1e68404cfa0e02706 (diff)
downloadcpython-526b22657cb18fe79118c2ea68511aca09430c2c.zip
cpython-526b22657cb18fe79118c2ea68511aca09430c2c.tar.gz
cpython-526b22657cb18fe79118c2ea68511aca09430c2c.tar.bz2
bpo-30602: Fix refleak in os.spawnve() (#2184)
When os.spawnve() fails while handling arguments, free correctly argvlist: pass lastarg+1 rather than lastarg to free_string_array() to also free the first item.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 6b1e435..4707029 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -5223,7 +5223,7 @@ os_spawnve_impl(PyObject *module, int mode, path_t *path, PyObject *argv,
Py_ssize_t argc, i, envc;
intptr_t spawnval;
PyObject *(*getitem)(PyObject *, Py_ssize_t);
- Py_ssize_t lastarg = 0;
+ Py_ssize_t lastarg = -1;
/* spawnve has four arguments: (mode, path, argv, env), where
argv is a list or tuple of strings and env is a dictionary
@@ -5302,7 +5302,7 @@ os_spawnve_impl(PyObject *module, int mode, path_t *path, PyObject *argv,
PyMem_DEL(envlist[envc]);
PyMem_DEL(envlist);
fail_1:
- free_string_array(argvlist, lastarg);
+ free_string_array(argvlist, lastarg + 1);
fail_0:
return res;
}