diff Python/modsupport.c @ 36774:35612a131ac6 legacy-trunk

Fix more memory leaks. Will backport to 2.4.
author Martin v. Löwis <martin@v.loewis.de>
date Wed, 01 Mar 2006 21:33:54 +0000
parents 30aef3ce2b26
children 7fac5d79d043
line wrap: on
line diff
--- a/Python/modsupport.c	Wed Mar 01 21:31:21 2006 +0000
+++ b/Python/modsupport.c	Wed Mar 01 21:33:54 2006 +0000
@@ -71,13 +71,17 @@
 				PyErr_SetString(PyExc_ValueError,
 						"module functions cannot set"
 						" METH_CLASS or METH_STATIC");
+				Py_DECREF(n);
 				return NULL;
 			}
 			v = PyCFunction_NewEx(ml, passthrough, n);
-			if (v == NULL)
+			if (v == NULL) {
+				Py_DECREF(n);
 				return NULL;
+			}
 			if (PyDict_SetItemString(d, ml->ml_name, v) != 0) {
 				Py_DECREF(v);
+				Py_DECREF(n);
 				return NULL;
 			}
 			Py_DECREF(v);