summaryrefslogtreecommitdiff
path: root/PC
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-06-04 22:15:37 +0000
committerGeorg Brandl <georg@python.org>2006-06-04 22:15:37 +0000
commit03e178e9eba80883a289ca629daa793b2770fb26 (patch)
tree7def226a9244ec9c7a47c849d49f4d0d14f42a9e /PC
parent889375ce0c39cbfb133a7b673399090bc0b969c2 (diff)
downloadcpython-03e178e9eba80883a289ca629daa793b2770fb26.tar.gz
Bug #1500293: fix memory leaks in _subprocess module.
Diffstat (limited to 'PC')
-rw-r--r--PC/_subprocess.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/PC/_subprocess.c b/PC/_subprocess.c
index 2e724c6211..c93f84bd1f 100644
--- a/PC/_subprocess.c
+++ b/PC/_subprocess.c
@@ -250,19 +250,23 @@ static int
getint(PyObject* obj, char* name)
{
PyObject* value;
+ int ret;
value = PyObject_GetAttrString(obj, name);
if (! value) {
PyErr_Clear(); /* FIXME: propagate error? */
return 0;
}
- return (int) PyInt_AsLong(value);
+ ret = (int) PyInt_AsLong(value);
+ Py_DECREF(value);
+ return ret;
}
static HANDLE
gethandle(PyObject* obj, char* name)
{
sp_handle_object* value;
+ HANDLE ret;
value = (sp_handle_object*) PyObject_GetAttrString(obj, name);
if (! value) {
@@ -270,8 +274,11 @@ gethandle(PyObject* obj, char* name)
return NULL;
}
if (value->ob_type != &sp_handle_type)
- return NULL;
- return value->handle;
+ ret = NULL;
+ else
+ ret = value->handle;
+ Py_DECREF(value);
+ return ret;
}
static PyObject*