From 55af3dd075c9191e740bdbff20ea886a812df811 Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Wed, 14 Dec 2022 17:20:05 +0100 Subject: [PATCH] shell: Clear command buffer when leaving bypass mode If bypass mode is left outside of the registered bypass handler, the command buffer was not cleared, basically containig leftovers from the processing of the previous command. This resulted in undefined behaviour on consecutive shell operations. Signed-off-by: Robert Lubos --- subsys/shell/shell.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/subsys/shell/shell.c b/subsys/shell/shell.c index 1311f1cafed..edd2feaf03a 100644 --- a/subsys/shell/shell.c +++ b/subsys/shell/shell.c @@ -1690,6 +1690,10 @@ void shell_set_bypass(const struct shell *sh, shell_bypass_cb_t bypass) __ASSERT_NO_MSG(sh); sh->ctx->bypass = bypass; + + if (bypass == NULL) { + cmd_buffer_clear(sh); + } } bool shell_ready(const struct shell *sh)