mirror of
https://github.com/python/cpython.git
synced 2025-07-29 22:24:49 +00:00
Bug #1500293: fix memory leaks in _subprocess module.
This commit is contained in:
parent
ddbaa660d3
commit
ad62489e47
2 changed files with 15 additions and 8 deletions
|
@ -388,6 +388,7 @@ if mswindows:
|
||||||
hStdInput = None
|
hStdInput = None
|
||||||
hStdOutput = None
|
hStdOutput = None
|
||||||
hStdError = None
|
hStdError = None
|
||||||
|
wShowWindow = 0
|
||||||
class pywintypes:
|
class pywintypes:
|
||||||
error = IOError
|
error = IOError
|
||||||
else:
|
else:
|
||||||
|
@ -744,18 +745,17 @@ class Popen(object):
|
||||||
args = list2cmdline(args)
|
args = list2cmdline(args)
|
||||||
|
|
||||||
# Process startup details
|
# Process startup details
|
||||||
default_startupinfo = STARTUPINFO()
|
|
||||||
if startupinfo is None:
|
if startupinfo is None:
|
||||||
startupinfo = default_startupinfo
|
startupinfo = STARTUPINFO()
|
||||||
if not None in (p2cread, c2pwrite, errwrite):
|
if None not in (p2cread, c2pwrite, errwrite):
|
||||||
startupinfo.dwFlags |= STARTF_USESTDHANDLES
|
startupinfo.dwFlags |= STARTF_USESTDHANDLES
|
||||||
startupinfo.hStdInput = p2cread
|
startupinfo.hStdInput = p2cread
|
||||||
startupinfo.hStdOutput = c2pwrite
|
startupinfo.hStdOutput = c2pwrite
|
||||||
startupinfo.hStdError = errwrite
|
startupinfo.hStdError = errwrite
|
||||||
|
|
||||||
if shell:
|
if shell:
|
||||||
default_startupinfo.dwFlags |= STARTF_USESHOWWINDOW
|
startupinfo.dwFlags |= STARTF_USESHOWWINDOW
|
||||||
default_startupinfo.wShowWindow = SW_HIDE
|
startupinfo.wShowWindow = SW_HIDE
|
||||||
comspec = os.environ.get("COMSPEC", "cmd.exe")
|
comspec = os.environ.get("COMSPEC", "cmd.exe")
|
||||||
args = comspec + " /c " + args
|
args = comspec + " /c " + args
|
||||||
if (GetVersion() >= 0x80000000L or
|
if (GetVersion() >= 0x80000000L or
|
||||||
|
|
|
@ -250,19 +250,23 @@ static int
|
||||||
getint(PyObject* obj, char* name)
|
getint(PyObject* obj, char* name)
|
||||||
{
|
{
|
||||||
PyObject* value;
|
PyObject* value;
|
||||||
|
int ret;
|
||||||
|
|
||||||
value = PyObject_GetAttrString(obj, name);
|
value = PyObject_GetAttrString(obj, name);
|
||||||
if (! value) {
|
if (! value) {
|
||||||
PyErr_Clear(); /* FIXME: propagate error? */
|
PyErr_Clear(); /* FIXME: propagate error? */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return (int) PyInt_AsLong(value);
|
ret = (int) PyInt_AsLong(value);
|
||||||
|
Py_DECREF(value);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HANDLE
|
static HANDLE
|
||||||
gethandle(PyObject* obj, char* name)
|
gethandle(PyObject* obj, char* name)
|
||||||
{
|
{
|
||||||
sp_handle_object* value;
|
sp_handle_object* value;
|
||||||
|
HANDLE ret;
|
||||||
|
|
||||||
value = (sp_handle_object*) PyObject_GetAttrString(obj, name);
|
value = (sp_handle_object*) PyObject_GetAttrString(obj, name);
|
||||||
if (! value) {
|
if (! value) {
|
||||||
|
@ -270,8 +274,11 @@ gethandle(PyObject* obj, char* name)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (value->ob_type != &sp_handle_type)
|
if (value->ob_type != &sp_handle_type)
|
||||||
return NULL;
|
ret = NULL;
|
||||||
return value->handle;
|
else
|
||||||
|
ret = value->handle;
|
||||||
|
Py_DECREF(value);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue