8000 Prevent a heap pointer from living on the stack longer than we need. · rbarraud/circuitpython@3b511e5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3b511e5

Browse files
tannewtdhalbert
authored andcommitted
Prevent a heap pointer from living on the stack longer than we need.
1 parent eb7d0e3 commit 3b511e5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/utils/pyexec.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input
9090
qstr source_name = lex->source_name;
9191
mp_parse_tree_t parse_tree = mp_parse(lex, input_kind);
9292
module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, exec_flags & EXEC_FLAG_IS_REPL);
93+
// Clear the parse tree because it has a heap pointer we don't need anymore.
94+
*((uint32_t volatile*) &parse_tree.chunk) = 0;
9395
#else
9496
mp_raise_msg(&mp_type_RuntimeError, "script compilation not supported");
9597
#endif

0 commit comments

Comments
 (0)
0