diff options
author | Damien George <damien.p.george@gmail.com> | 2014-01-23 14:27:40 -0800 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-01-23 14:27:40 -0800 |
commit | d552db426b3b79813a6269e4c18519b2d22195e4 (patch) | |
tree | 9b13316843e02bd5587b24f668d3783f578e0318 /py/compile.c | |
parent | 3257d3543becc23b045c94e99f814e80d306d235 (diff) | |
parent | fd31358505dd794feb153c00bec6d4ee92c851d1 (diff) |
Merge pull request #214 from pfalcon/compile-mem-leaks
Memory leaks in lexer/compiler
Diffstat (limited to 'py/compile.c')
-rw-r--r-- | py/compile.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/py/compile.c b/py/compile.c index 0704cc457..7e77832bc 100644 --- a/py/compile.c +++ b/py/compile.c @@ -3156,6 +3156,12 @@ mp_obj_t mp_compile(mp_parse_node_t pn, qstr source_file, bool is_repl) { bool had_error = comp->had_error; m_del_obj(compiler_t, comp); + uint unique_code_id = module_scope->unique_code_id; + for (scope_t *s = module_scope; s;) { + scope_t *next = s->next; + scope_free(s); + s = next; + } if (had_error) { // TODO return a proper error message @@ -3163,11 +3169,11 @@ mp_obj_t mp_compile(mp_parse_node_t pn, qstr source_file, bool is_repl) { } else { #if MICROPY_EMIT_CPYTHON // can't create code, so just return true - (void)module_scope; // to suppress warning that module_scope is unused + (void)unique_code_id; // to suppress warning that module_scope is unused return mp_const_true; #else // return function that executes the outer module - return rt_make_function_from_id(module_scope->unique_code_id); + return rt_make_function_from_id(unique_code_id); #endif } } |