diff PC/_subprocess.c @ 38590:913e5e84fade 2.4

Bug #1500293: fix memory leaks in _subprocess module. (backport from rev. 46651)
author Georg Brandl <georg@python.org>
date Sun, 04 Jun 2006 22:15:45 +0000
parents 66223a9ebe48
children 6fb46e87d5f9
line wrap: on
line diff
--- a/PC/_subprocess.c	Sat Jun 03 20:34:33 2006 +0000
+++ b/PC/_subprocess.c	Sun Jun 04 22:15:45 2006 +0000
@@ -247,19 +247,23 @@
 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) {
@@ -267,8 +271,11 @@
 		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*