Skip to content

Commit d203d1c

Browse files
authored
Merge pull request #750 from tannewt/parse_tree_memory
Prevent a heap pointer from living on the stack longer than we need.
2 parents e7b8b13 + 7dd1d6a commit d203d1c

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy