summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--components/finsh/msh.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/components/finsh/msh.c b/components/finsh/msh.c
index 73a5197dcd..ed12219c2e 100644
--- a/components/finsh/msh.c
+++ b/components/finsh/msh.c
@@ -374,7 +374,7 @@ int msh_exec(char *cmd, rt_size_t length)
int cmd_ret;
/* strim the beginning of command */
- while (*cmd == ' ' || *cmd == '\t')
+ while ((length > 0) && (*cmd == ' ' || *cmd == '\t'))
{
cmd++;
length--;