]> granicus.if.org Git - python/commitdiff
bpo-30602: Fix refleak in os.spawnv() (#2212) (#2486)
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 29 Jun 2017 08:53:22 +0000 (10:53 +0200)
committerGitHub <noreply@github.com>
Thu, 29 Jun 2017 08:53:22 +0000 (10:53 +0200)
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

index 4607b181c6cea6d91834bd7df706daa9c345fabf..c205dd9b054afd4c805696a21a763976e5709a0c 100644 (file)
@@ -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");