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--;