diff Python/bltinmodule.c @ 44893:fdd74bdeee15 2.5

Fix two crashers (borrowed_ref_[34].py from the trunk).
author Guido van Rossum <guido@python.org>
date Wed, 23 Jan 2008 20:09:39 +0000
parents 97d3eab8cda2
children 8cbe0bd93c28
line wrap: on
line diff
--- a/Python/bltinmodule.c	Wed Jan 23 17:54:14 2008 +0000
+++ b/Python/bltinmodule.c	Wed Jan 23 20:09:39 2008 +0000
@@ -1218,11 +1218,14 @@
 				"%s() got an unexpected keyword argument", name);
 			return NULL;
 		}
+		Py_INCREF(keyfunc);
 	}
 
 	it = PyObject_GetIter(v);
-	if (it == NULL)
+	if (it == NULL) {
+		Py_XDECREF(keyfunc);
 		return NULL;
+	}
 
 	maxitem = NULL; /* the result */
 	maxval = NULL;  /* the value associated with the result */
@@ -1271,6 +1274,7 @@
 	else
 		Py_DECREF(maxval);
 	Py_DECREF(it);
+	Py_XDECREF(keyfunc);
 	return maxitem;
 
 Fail_it_item_and_val:
@@ -1281,6 +1285,7 @@
 	Py_XDECREF(maxval);
 	Py_XDECREF(maxitem);
 	Py_DECREF(it);
+	Py_XDECREF(keyfunc);
 	return NULL;
 }