summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-06-15 13:30:40 (GMT)
committerGitHub <noreply@github.com>2017-06-15 13:30:40 (GMT)
commit8acb4cf2b3436652568d7a70228b166316181466 (patch)
treed5bee2487229c7290dff47b2906b66227ed1fb02 /Modules/posixmodule.c
parent7926516ff95ed9c8345ed4c4c4910f44ffbd5949 (diff)
downloadcpython-8acb4cf2b3436652568d7a70228b166316181466.zip
cpython-8acb4cf2b3436652568d7a70228b166316181466.tar.gz
cpython-8acb4cf2b3436652568d7a70228b166316181466.tar.bz2
bpo-30602: Fix refleak in os.spawnv() (#2212)
When os.spawnv() 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.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 4707029..ff03b8d 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -5165,7 +5165,7 @@ os_spawnv_impl(PyObject *module, int mode, path_t *path, PyObject *argv)
return NULL;
}
if (i == 0 && !argvlist[0][0]) {
- free_string_array(argvlist, i);
+ free_string_array(argvlist, i + 1);
PyErr_SetString(
PyExc_ValueError,
"spawnv() arg 2 first element cannot be empty");