diff Python/symtable.c @ 54025:5fce14e1d703

fix error handling of PyNumber_InPlaceOr #6000
author Benjamin Peterson <benjamin@python.org>
date Tue, 12 May 2009 20:39:25 +0000
parents a0e211b04b2e
children fd6e2abae14e 0704f15b4682
line wrap: on
line diff
--- a/Python/symtable.c	Tue May 12 17:14:01 2009 +0000
+++ b/Python/symtable.c	Tue May 12 20:39:25 2009 +0000
@@ -658,6 +658,7 @@
 {
 	PyObject *name, *v, *local = NULL, *scopes = NULL, *newbound = NULL;
 	PyObject *newglobal = NULL, *newfree = NULL, *allfree = NULL;
+	PyObject *temp;
 	int i, success = 0;
 	Py_ssize_t pos = 0;
 
@@ -696,14 +697,16 @@
 	 */
 	if (ste->ste_type == ClassBlock) {
 		/* Pass down known globals */
-		if (!PyNumber_InPlaceOr(newglobal, global))
+		temp = PyNumber_InPlaceOr(newglobal, global);
+		if (!temp)
 			goto error;
-		Py_DECREF(newglobal);
+		Py_DECREF(temp);
 		/* Pass down previously bound symbols */
 		if (bound) {
-			if (!PyNumber_InPlaceOr(newbound, bound))
+			temp = PyNumber_InPlaceOr(newbound, bound);
+			if (!temp)
 				goto error;
-			Py_DECREF(newbound);
+			Py_DECREF(temp);
 		}
 	}
 
@@ -718,20 +721,23 @@
 	if (ste->ste_type != ClassBlock) {
 		/* Add function locals to bound set */
 		if (ste->ste_type == FunctionBlock) {
-			if (!PyNumber_InPlaceOr(newbound, local))
+			temp = PyNumber_InPlaceOr(newbound, local);
+			if (!temp)
 				goto error;
-			Py_DECREF(newbound);
+			Py_DECREF(temp);
 		}
 		/* Pass down previously bound symbols */
 		if (bound) {
-			if (!PyNumber_InPlaceOr(newbound, bound))
+			temp = PyNumber_InPlaceOr(newbound, bound);
+			if (!temp)
 				goto error;
-			Py_DECREF(newbound);
+			Py_DECREF(temp);
 		}
 		/* Pass down known globals */
-		if (!PyNumber_InPlaceOr(newglobal, global))
+		temp = PyNumber_InPlaceOr(newglobal, global);
+		if (!temp)
 			goto error;
-		Py_DECREF(newglobal);
+		Py_DECREF(temp);
 	}
 	else {
 		/* Special-case __class__ */
@@ -764,9 +770,10 @@
 			ste->ste_child_free = 1;
 	}
 
-	if (PyNumber_InPlaceOr(newfree, allfree) < 0)
+	temp = PyNumber_InPlaceOr(newfree, allfree);
+	if (!temp)
 		goto error;
-	Py_DECREF(newfree);
+	Py_DECREF(temp);
 
 	/* Check if any local variables must be converted to cell variables */
 	if (ste->ste_type == FunctionBlock && !analyze_cells(scopes, newfree,
@@ -782,9 +789,10 @@
 	if (!check_unoptimized(ste))
 		goto error;
 
-	if (!PyNumber_InPlaceOr(free, newfree))
+	temp = PyNumber_InPlaceOr(free, newfree);
+	if (!temp)
 		goto error;
-	Py_DECREF(free);
+	Py_DECREF(temp);
 	success = 1;
  error:
 	Py_XDECREF(scopes);
@@ -803,6 +811,7 @@
 		    PyObject *global, PyObject* child_free)
 {
 	PyObject *temp_bound = NULL, *temp_global = NULL, *temp_free = NULL;
+	PyObject *temp;
 
 	/* Copy the bound and global dictionaries.
 
@@ -823,9 +832,10 @@
 
 	if (!analyze_block(entry, temp_bound, temp_free, temp_global))
 		goto error;
-	if (PyNumber_InPlaceOr(child_free, temp_free) < 0)
+	temp = PyNumber_InPlaceOr(child_free, temp_free);
+	if (!temp)
 		goto error;
-	Py_DECREF(child_free);
+	Py_DECREF(temp);
 	Py_DECREF(temp_bound);
 	Py_DECREF(temp_free);
 	Py_DECREF(temp_global);