Skip to content

Commit

Permalink
Fix for crash caused by sending CMD_TERMINATOR without having sent an…
Browse files Browse the repository at this point in the history
…y data first
  • Loading branch information
ovylnoah committed Jul 1, 2024
1 parent 10d35d0 commit 64bc81a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ cli_status_t cli_put(cli_t *cli, char c)
{
case CMD_TERMINATOR:
{
if(rx_data.current_buf_length == 0)
{
break; //Do nothing if we have not received any data
}

/* Terminate the msg and reset the msg ptr by subtracting the length. This should put us back at the beginning of the array */
*rx_data.buf_ptr = '\0';
rx_data.buf_ptr -= rx_data.current_buf_length;
Expand Down

0 comments on commit 64bc81a

Please sign in to comment.