Prevent a heap pointer from living on the stack longer than we need.
This commit is contained in:
parent
eb7d0e317a
commit
3b511e503a
@ -90,6 +90,8 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input
|
|||||||
qstr source_name = lex->source_name;
|
qstr source_name = lex->source_name;
|
||||||
mp_parse_tree_t parse_tree = mp_parse(lex, input_kind);
|
mp_parse_tree_t parse_tree = mp_parse(lex, input_kind);
|
||||||
module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, exec_flags & EXEC_FLAG_IS_REPL);
|
module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, exec_flags & EXEC_FLAG_IS_REPL);
|
||||||
|
// Clear the parse tree because it has a heap pointer we don't need anymore.
|
||||||
|
*((uint32_t volatile*) &parse_tree.chunk) = 0;
|
||||||
#else
|
#else
|
||||||
mp_raise_msg(&mp_type_RuntimeError, "script compilation not supported");
|
mp_raise_msg(&mp_type_RuntimeError, "script compilation not supported");
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user