summaryrefslogtreecommitdiff
path: root/Python/symtable.c
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-07-21 07:59:47 +0000
committerNeal Norwitz <nnorwitz@gmail.com>2006-07-21 07:59:47 +0000
commitd12bd012a6a4729b5a77c1019ca9da4e9d1b7e3e (patch)
treef80aa311a6efe044d51c07f42e734b750be129be /Python/symtable.c
parent33722aec5755f1fa8c0660094639174dbbeefb1d (diff)
downloadcpython-git-d12bd012a6a4729b5a77c1019ca9da4e9d1b7e3e.tar.gz
Handle more memory allocation failures without crashing.
Diffstat (limited to 'Python/symtable.c')
-rw-r--r--Python/symtable.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/Python/symtable.c b/Python/symtable.c
index 1dc2a2ea74..fae9208a66 100644
--- a/Python/symtable.c
+++ b/Python/symtable.c
@@ -221,8 +221,12 @@ PySymtable_Build(mod_ty mod, const char *filename, PyFutureFeatures *future)
return st;
st->st_filename = filename;
st->st_future = future;
- symtable_enter_block(st, GET_IDENTIFIER(top), ModuleBlock,
- (void *)mod, 0);
+ if (!symtable_enter_block(st, GET_IDENTIFIER(top), ModuleBlock,
+ (void *)mod, 0)) {
+ PySymtable_Free(st);
+ return NULL;
+ }
+
st->st_top = st->st_cur;
st->st_cur->ste_unoptimized = OPT_TOPLEVEL;
/* Any other top-level initialization? */
@@ -728,6 +732,8 @@ symtable_exit_block(struct symtable *st, void *ast)
if (end >= 0) {
st->st_cur = (PySTEntryObject *)PyList_GET_ITEM(st->st_stack,
end);
+ if (st->st_cur == NULL)
+ return 0;
Py_INCREF(st->st_cur);
if (PySequence_DelItem(st->st_stack, end) < 0)
return 0;
@@ -749,6 +755,8 @@ symtable_enter_block(struct symtable *st, identifier name, _Py_block_ty block,
Py_DECREF(st->st_cur);
}
st->st_cur = PySTEntry_New(st, name, block, ast, lineno);
+ if (st->st_cur == NULL)
+ return 0;
if (name == GET_IDENTIFIER(top))
st->st_global = st->st_cur->ste_symbols;
if (prev) {