From 4ce3e33447cf831c9616f54a99b09ebaaabd175d Mon Sep 17 00:00:00 2001 From: d00f <8052722+DrDoof@users.noreply.github.com> Date: Tue, 1 Sep 2026 09:02:28 +0200 Subject: [PATCH] cmd: keep the history pointer inside the ring The pointer is masked when it advances over the command text, then incremented once more for the newline without masking, so it can come to rest one past the end of the ring. Both readers walk from the pointer with their own index masked every step, so an index that sits outside the ring is never reached and the walk does not end. `history` on the console spins there, and so does `/cmd_log`, which the web page fetches whenever settings are saved: it fills the transmit buffer and keeps going past it. --- cmd_parser.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd_parser.c b/cmd_parser.c index 66b05bd..36173e7 100644 --- a/cmd_parser.c +++ b/cmd_parser.c @@ -1771,7 +1771,8 @@ void cmd_parser(void) __banked // Copy last cmd-buffer to history. cmd_history_ptr = (cmd_history_ptr + i) & CMD_HISTORY_MASK; __xdata uint16_t p = cmd_history_ptr; - cmd_history[cmd_history_ptr++] = '\n'; + cmd_history[cmd_history_ptr] = '\n'; + cmd_history_ptr = (cmd_history_ptr + 1) & CMD_HISTORY_MASK; do { i--; cmd_history[--p & CMD_HISTORY_MASK] = cmd_buffer[i];