fix error handling of PyNumber_InPlaceOr #6000

This commit is contained in:
Benjamin Peterson 2009-05-12 20:39:25 +00:00
parent ff0e5002ba
commit 57512588fa

View file

@ -658,6 +658,7 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free,
{ {
PyObject *name, *v, *local = NULL, *scopes = NULL, *newbound = NULL; PyObject *name, *v, *local = NULL, *scopes = NULL, *newbound = NULL;
PyObject *newglobal = NULL, *newfree = NULL, *allfree = NULL; PyObject *newglobal = NULL, *newfree = NULL, *allfree = NULL;
PyObject *temp;
int i, success = 0; int i, success = 0;
Py_ssize_t pos = 0; Py_ssize_t pos = 0;
@ -696,14 +697,16 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free,
*/ */
if (ste->ste_type == ClassBlock) { if (ste->ste_type == ClassBlock) {
/* Pass down known globals */ /* Pass down known globals */
if (!PyNumber_InPlaceOr(newglobal, global)) temp = PyNumber_InPlaceOr(newglobal, global);
if (!temp)
goto error; goto error;
Py_DECREF(newglobal); Py_DECREF(temp);
/* Pass down previously bound symbols */ /* Pass down previously bound symbols */
if (bound) { if (bound) {
if (!PyNumber_InPlaceOr(newbound, bound)) temp = PyNumber_InPlaceOr(newbound, bound);
if (!temp)
goto error; goto error;
Py_DECREF(newbound); Py_DECREF(temp);
} }
} }
@ -718,20 +721,23 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free,
if (ste->ste_type != ClassBlock) { if (ste->ste_type != ClassBlock) {
/* Add function locals to bound set */ /* Add function locals to bound set */
if (ste->ste_type == FunctionBlock) { if (ste->ste_type == FunctionBlock) {
if (!PyNumber_InPlaceOr(newbound, local)) temp = PyNumber_InPlaceOr(newbound, local);
if (!temp)
goto error; goto error;
Py_DECREF(newbound); Py_DECREF(temp);
} }
/* Pass down previously bound symbols */ /* Pass down previously bound symbols */
if (bound) { if (bound) {
if (!PyNumber_InPlaceOr(newbound, bound)) temp = PyNumber_InPlaceOr(newbound, bound);
if (!temp)
goto error; goto error;
Py_DECREF(newbound); Py_DECREF(temp);
} }
/* Pass down known globals */ /* Pass down known globals */
if (!PyNumber_InPlaceOr(newglobal, global)) temp = PyNumber_InPlaceOr(newglobal, global);
if (!temp)
goto error; goto error;
Py_DECREF(newglobal); Py_DECREF(temp);
} }
else { else {
/* Special-case __class__ */ /* Special-case __class__ */
@ -764,9 +770,10 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free,
ste->ste_child_free = 1; ste->ste_child_free = 1;
} }
if (PyNumber_InPlaceOr(newfree, allfree) < 0) temp = PyNumber_InPlaceOr(newfree, allfree);
if (!temp)
goto error; goto error;
Py_DECREF(newfree); Py_DECREF(temp);
/* Check if any local variables must be converted to cell variables */ /* Check if any local variables must be converted to cell variables */
if (ste->ste_type == FunctionBlock && !analyze_cells(scopes, newfree, if (ste->ste_type == FunctionBlock && !analyze_cells(scopes, newfree,
@ -782,9 +789,10 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free,
if (!check_unoptimized(ste)) if (!check_unoptimized(ste))
goto error; goto error;
if (!PyNumber_InPlaceOr(free, newfree)) temp = PyNumber_InPlaceOr(free, newfree);
if (!temp)
goto error; goto error;
Py_DECREF(free); Py_DECREF(temp);
success = 1; success = 1;
error: error:
Py_XDECREF(scopes); Py_XDECREF(scopes);
@ -803,6 +811,7 @@ analyze_child_block(PySTEntryObject *entry, PyObject *bound, PyObject *free,
PyObject *global, PyObject* child_free) PyObject *global, PyObject* child_free)
{ {
PyObject *temp_bound = NULL, *temp_global = NULL, *temp_free = NULL; PyObject *temp_bound = NULL, *temp_global = NULL, *temp_free = NULL;
PyObject *temp;
/* Copy the bound and global dictionaries. /* Copy the bound and global dictionaries.
@ -823,9 +832,10 @@ analyze_child_block(PySTEntryObject *entry, PyObject *bound, PyObject *free,
if (!analyze_block(entry, temp_bound, temp_free, temp_global)) if (!analyze_block(entry, temp_bound, temp_free, temp_global))
goto error; goto error;
if (PyNumber_InPlaceOr(child_free, temp_free) < 0) temp = PyNumber_InPlaceOr(child_free, temp_free);
if (!temp)
goto error; goto error;
Py_DECREF(child_free); Py_DECREF(temp);
Py_DECREF(temp_bound); Py_DECREF(temp_bound);
Py_DECREF(temp_free); Py_DECREF(temp_free);
Py_DECREF(temp_global); Py_DECREF(temp_global);