Skip to content

Commit a591a47

Browse files
authored
Avoid wrapping size_t to -1 (#37)
Avoids: embedded_cli.c:89:13: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'size_t' (aka 'unsigned long')
1 parent 8b96e8a commit a591a47

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

embedded_cli.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,8 @@ static void term_cursor_fwd(struct embedded_cli *cli, size_t n)
8585
#if EMBEDDED_CLI_HISTORY_LEN
8686
static void term_backspace(struct embedded_cli *cli, size_t n)
8787
{
88-
// printf("backspace %d ('%s': %d)\n", n, cli->buffer, cli->done);
89-
while (n--)
90-
cli_putchar(cli, '\b', n == 0);
88+
for (; n > 0; n--)
89+
cli_putchar(cli, '\b', n == 1);
9190
}
9291

9392
static const char *embedded_cli_get_history_search(struct embedded_cli *cli)

0 commit comments

Comments
 (0)