diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-05-12 20:39:25 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-05-12 20:39:25 (GMT) |
commit | 57512588fa4178860d6f10175d75a672e8c396c2 (patch) | |
tree | 3dddd4bf2e2f56ce62b9f29b3d4239805b15f1ae /Python/symtable.c | |
parent | ff0e5002ba2458821f4172a4c186797f39914ed2 (diff) | |
download | cpython-57512588fa4178860d6f10175d75a672e8c396c2.zip cpython-57512588fa4178860d6f10175d75a672e8c396c2.tar.gz cpython-57512588fa4178860d6f10175d75a672e8c396c2.tar.bz2 |
fix error handling of PyNumber_InPlaceOr #6000
Diffstat (limited to 'Python/symtable.c')
-rw-r--r-- | Python/symtable.c | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/Python/symtable.c b/Python/symtable.c index d0a0c5d..f10e382 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -658,6 +658,7 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, { 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 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, */ 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 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, 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 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, 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 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, 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 @@ analyze_child_block(PySTEntryObject *entry, PyObject *bound, PyObject *free, 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 @@ analyze_child_block(PySTEntryObject *entry, PyObject *bound, PyObject *free, 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); |