diff Python/bltinmodule.c @ 44894:4c8308ac20cd legacy-trunk

Fix two crashers.
author Guido van Rossum <guido@python.org>
date Wed, 23 Jan 2008 20:19:01 +0000
parents 8da9ebf73026
children e791bb0adcde
line wrap: on
line diff
--- a/Python/bltinmodule.c	Wed Jan 23 17:15:06 2008 +0000
+++ b/Python/bltinmodule.c	Wed Jan 23 20:19:01 2008 +0000
@@ -1245,11 +1245,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 */
@@ -1298,6 +1301,7 @@
 	else
 		Py_DECREF(maxval);
 	Py_DECREF(it);
+	Py_XDECREF(keyfunc);
 	return maxitem;
 
 Fail_it_item_and_val:
@@ -1308,6 +1312,7 @@
 	Py_XDECREF(maxval);
 	Py_XDECREF(maxitem);
 	Py_DECREF(it);
+	Py_XDECREF(keyfunc);
 	return NULL;
 }