From 71498376c9df8fc702bba0712c2f68ccc013a3cf Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 15 Jun 2017 15:30:40 +0200 Subject: [PATCH] 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. (cherry picked from commit 8acb4cf2b3436652568d7a70228b166316181466) --- Modules/posixmodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 4607b181c6cea6..c205dd9b054afd 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -5106,7 +5106,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");