diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2005-12-18 04:42:47 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2005-12-18 04:42:47 (GMT) |
commit | 87b801cc2dc99caa80a442dbf02ede350d3fc342 (patch) | |
tree | 98fe3a7fa02d85451fbaaeb8ea5bc72625c3cf57 /Python | |
parent | 3c52c5a888a5a49fac712336f117ed91aa37b4b8 (diff) | |
download | cpython-87b801cc2dc99caa80a442dbf02ede350d3fc342.zip cpython-87b801cc2dc99caa80a442dbf02ede350d3fc342.tar.gz cpython-87b801cc2dc99caa80a442dbf02ede350d3fc342.tar.bz2 |
Set MemoryError when alloc fails
Diffstat (limited to 'Python')
-rw-r--r-- | Python/compile.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/Python/compile.c b/Python/compile.c index accd3b7..84f52e6 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1075,12 +1075,16 @@ compiler_enter_scope(struct compiler *c, identifier name, void *key, struct compiler_unit *u; u = PyObject_Malloc(sizeof(struct compiler_unit)); + if (!u) { + PyErr_NoMemory(); + return 0; + } memset(u, 0, sizeof(struct compiler_unit)); u->u_argcount = 0; u->u_ste = PySymtable_Lookup(c->c_st, key); if (!u->u_ste) { compiler_unit_free(u); - return 0; + return 0; } Py_INCREF(name); u->u_name = name; @@ -1163,8 +1167,10 @@ compiler_new_block(struct compiler *c) u = c->u; b = (basicblock *)PyObject_Malloc(sizeof(basicblock)); - if (b == NULL) + if (b == NULL) { + PyErr_NoMemory(); return NULL; + } memset((void *)b, 0, sizeof(basicblock)); assert (b->b_next == NULL); b->b_list = u->u_blocks; @@ -3747,8 +3753,10 @@ assemble_init(struct assembler *a, int nblocks, int firstlineno) return 0; a->a_postorder = (basicblock **)PyObject_Malloc( sizeof(basicblock *) * nblocks); - if (!a->a_postorder) + if (!a->a_postorder) { + PyErr_NoMemory(); return 0; + } return 1; } |