mirror of
https://github.com/python/cpython.git
synced 2025-11-08 13:42:22 +00:00
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.
This commit is contained in:
parent
3402f72688
commit
526b22657c
1 changed files with 2 additions and 2 deletions
|
|
@ -5223,7 +5223,7 @@ os_spawnve_impl(PyObject *module, int mode, path_t *path, PyObject *argv,
|
||||||
Py_ssize_t argc, i, envc;
|
Py_ssize_t argc, i, envc;
|
||||||
intptr_t spawnval;
|
intptr_t spawnval;
|
||||||
PyObject *(*getitem)(PyObject *, Py_ssize_t);
|
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
|
/* spawnve has four arguments: (mode, path, argv, env), where
|
||||||
argv is a list or tuple of strings and env is a dictionary
|
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[envc]);
|
||||||
PyMem_DEL(envlist);
|
PyMem_DEL(envlist);
|
||||||
fail_1:
|
fail_1:
|
||||||
free_string_array(argvlist, lastarg);
|
free_string_array(argvlist, lastarg + 1);
|
||||||
fail_0:
|
fail_0:
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue