diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2006-07-21 07:59:47 +0000 |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2006-07-21 07:59:47 +0000 |
commit | d12bd012a6a4729b5a77c1019ca9da4e9d1b7e3e (patch) | |
tree | f80aa311a6efe044d51c07f42e734b750be129be /Python/compile.c | |
parent | 33722aec5755f1fa8c0660094639174dbbeefb1d (diff) | |
download | cpython-git-d12bd012a6a4729b5a77c1019ca9da4e9d1b7e3e.tar.gz |
Handle more memory allocation failures without crashing.
Diffstat (limited to 'Python/compile.c')
-rw-r--r-- | Python/compile.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Python/compile.c b/Python/compile.c index 8341cc93bb..3ee5cbbd6e 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1105,8 +1105,17 @@ compiler_enter_scope(struct compiler *c, identifier name, void *key, u->u_name = name; u->u_varnames = list2dict(u->u_ste->ste_varnames); u->u_cellvars = dictbytype(u->u_ste->ste_symbols, CELL, 0, 0); + if (!u->u_varnames || !u->u_cellvars) { + compiler_unit_free(u); + return 0; + } + u->u_freevars = dictbytype(u->u_ste->ste_symbols, FREE, DEF_FREE_CLASS, PyDict_Size(u->u_cellvars)); + if (!u->u_freevars) { + compiler_unit_free(u); + return 0; + } u->u_blocks = NULL; u->u_tmpname = 0; |