diff options
author | Alexey Izbyshev <izbyshev@ispras.ru> | 2020-10-26 00:09:32 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-26 00:09:32 (GMT) |
commit | c0590c0033e86f98cdf5f2ca6898656f98ab4053 (patch) | |
tree | bf2e01413ef7171bfc87b0802a201635515c2413 /Modules/_posixsubprocess.c | |
parent | e68c67805e6a4c4ec80bea64be0e8373cc02d322 (diff) | |
download | cpython-c0590c0033e86f98cdf5f2ca6898656f98ab4053.zip cpython-c0590c0033e86f98cdf5f2ca6898656f98ab4053.tar.gz cpython-c0590c0033e86f98cdf5f2ca6898656f98ab4053.tar.bz2 |
bpo-42146: Fix memory leak in subprocess.Popen() in case of uid/gid overflow (GH-22966)
Fix memory leak in subprocess.Popen() in case of uid/gid overflow
Also add a test that would catch this leak with `--huntrleaks`.
Alas, the test for `extra_groups` also exposes an inconsistency
in our error reporting: we use a custom ValueError for `extra_groups`,
but propagate OverflowError for `user` and `group`.
Diffstat (limited to 'Modules/_posixsubprocess.c')
-rw-r--r-- | Modules/_posixsubprocess.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c index 8baea31..5e5fbb2 100644 --- a/Modules/_posixsubprocess.c +++ b/Modules/_posixsubprocess.c @@ -772,7 +772,7 @@ subprocess_fork_exec(PyObject* self, PyObject *args) uid_t uid; gid_t gid, *groups = NULL; int child_umask; - PyObject *cwd_obj, *cwd_obj2; + PyObject *cwd_obj, *cwd_obj2 = NULL; const char *cwd; pid_t pid; int need_to_reenable_gc = 0; @@ -894,7 +894,6 @@ subprocess_fork_exec(PyObject* self, PyObject *args) cwd = PyBytes_AsString(cwd_obj2); } else { cwd = NULL; - cwd_obj2 = NULL; } if (groups_list != Py_None) { @@ -1080,6 +1079,7 @@ subprocess_fork_exec(PyObject* self, PyObject *args) return PyLong_FromPid(pid); cleanup: + Py_XDECREF(cwd_obj2); if (envp) _Py_FreeCharPArray(envp); if (argv) |