[Python-checkins] r60223 - python/branches/release25-maint/Python/bltinmodule.c python/branches/release25-maint/Python/ceval.c

guido.van.rossum python-checkins at python.org
Wed Jan 23 21:09:40 CET 2008


Author: guido.van.rossum
Date: Wed Jan 23 21:09:39 2008
New Revision: 60223

Modified:
   python/branches/release25-maint/Python/bltinmodule.c
   python/branches/release25-maint/Python/ceval.c
Log:
Fix two crashers (borrowed_ref_[34].py from the trunk).


Modified: python/branches/release25-maint/Python/bltinmodule.c
==============================================================================
--- python/branches/release25-maint/Python/bltinmodule.c	(original)
+++ python/branches/release25-maint/Python/bltinmodule.c	Wed Jan 23 21:09:39 2008
@@ -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;
 }
 

Modified: python/branches/release25-maint/Python/ceval.c
==============================================================================
--- python/branches/release25-maint/Python/ceval.c	(original)
+++ python/branches/release25-maint/Python/ceval.c	Wed Jan 23 21:09:39 2008
@@ -2036,6 +2036,7 @@
 						"__import__ not found");
 				break;
 			}
+			Py_INCREF(x);
 			v = POP();
 			u = TOP();
 			if (PyInt_AsLong(u) != -1 || PyErr_Occurred())
@@ -2057,11 +2058,14 @@
 			Py_DECREF(u);
 			if (w == NULL) {
 				u = POP();
+				Py_DECREF(x);
 				x = NULL;
 				break;
 			}
 			READ_TIMESTAMP(intr0);
-			x = PyEval_CallObject(x, w);
+			v = x;
+			x = PyEval_CallObject(v, w);
+			Py_DECREF(v);
 			READ_TIMESTAMP(intr1);
 			Py_DECREF(w);
 			SET_TOP(x);


More information about the Python-checkins mailing list