Mercurial > cpython-lru_cache-weakref
diff Python/symtable.c @ 39131:7c09b66f04bd legacy-trunk
Handle more memory allocation failures without crashing.
| author | Neal Norwitz <nnorwitz@gmail.com> |
|---|---|
| date | Fri, 21 Jul 2006 07:59:47 +0000 |
| parents | 5dfb21a37f19 |
| children | 12e973bdfeee |
line wrap: on
line diff
--- a/Python/symtable.c Fri Jul 21 07:59:02 2006 +0000 +++ b/Python/symtable.c Fri Jul 21 07:59:47 2006 +0000 @@ -221,8 +221,12 @@ 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 @@ 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 @@ 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) {
