diff options
Diffstat (limited to 'stmhal/pyexec.c')
-rw-r--r-- | stmhal/pyexec.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/stmhal/pyexec.c b/stmhal/pyexec.c index 1563dc8e4a..930c1c0191 100644 --- a/stmhal/pyexec.c +++ b/stmhal/pyexec.c @@ -248,11 +248,12 @@ int pyexec_friendly_repl_process_char(int c) { return 0; } + vstr_null_terminate(&repl.line); if (!mp_repl_continue_with_input(vstr_str(&repl.line))) { goto exec; } - vstr_add_char(&repl.line, '\n'); + vstr_add_byte(&repl.line, '\n'); repl.cont_line = true; stdout_tx_str("... "); readline_note_newline(); @@ -274,8 +275,9 @@ int pyexec_friendly_repl_process_char(int c) { return 0; } + vstr_null_terminate(&repl.line); if (mp_repl_continue_with_input(vstr_str(&repl.line))) { - vstr_add_char(&repl.line, '\n'); + vstr_add_byte(&repl.line, '\n'); stdout_tx_str("... "); readline_note_newline(); return 0; @@ -362,8 +364,12 @@ friendly_repl_reset: continue; } - while (mp_repl_continue_with_input(vstr_str(&line))) { - vstr_add_char(&line, '\n'); + for (;;) { + vstr_null_terminate(&line); + if (!mp_repl_continue_with_input(vstr_str(&line))) { + break; + } + vstr_add_byte(&line, '\n'); ret = readline(&line, "... "); if (ret == CHAR_CTRL_C) { // cancel everything |