diff options
author | Dave Hylands <dhylands@gmail.com> | 2018-09-12 11:01:45 -0700 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2018-09-14 13:27:43 +1000 |
commit | 1a2c511e5d0841a25c5e86f41dbfc50d94a18b50 (patch) | |
tree | 5e5acb6682cea72fad87cc8c101f20ab19a29d4f | |
parent | e62f59217bb1cbf2fd22ee942b284a4de3cc51ea (diff) |
examples/embedding: Fix reference to freed memory, lexer src name.
This issue was brought up by BramPeters in the forum:
https://forum.micropython.org/viewtopic.php?p=30066
-rw-r--r-- | examples/embedding/hello-embed.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/examples/embedding/hello-embed.c b/examples/embedding/hello-embed.c index 3473e5bcd..51c4108c2 100644 --- a/examples/embedding/hello-embed.c +++ b/examples/embedding/hello-embed.c @@ -38,9 +38,10 @@ static char heap[16384]; mp_obj_t execute_from_str(const char *str) { nlr_buf_t nlr; if (nlr_push(&nlr) == 0) { - mp_lexer_t *lex = mp_lexer_new_from_str_len(0/*MP_QSTR_*/, str, strlen(str), false); + qstr src_name = 0/*MP_QSTR_*/; + mp_lexer_t *lex = mp_lexer_new_from_str_len(src_name, str, strlen(str), false); mp_parse_tree_t pt = mp_parse(lex, MP_PARSE_FILE_INPUT); - mp_obj_t module_fun = mp_compile(&pt, lex->source_name, MP_EMIT_OPT_NONE, false); + mp_obj_t module_fun = mp_compile(&pt, src_name, MP_EMIT_OPT_NONE, false); mp_call_function_0(module_fun); nlr_pop(); return 0; |