From ff192a4a58580d0273effffed0c3c25f8e0eefcf Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 11 Aug 2018 09:30:53 -0600 Subject: [PATCH] apps/nshlib: I was able to cause an assertion with some typos in an testing the 'fi' command. Not an important thing, but this will protect against the assertion. --- nshlib/nsh_parse.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nshlib/nsh_parse.c b/nshlib/nsh_parse.c index 4abe135a1..ac142cdd9 100644 --- a/nshlib/nsh_parse.c +++ b/nshlib/nsh_parse.c @@ -1777,7 +1777,7 @@ static int nsh_loop(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, bool inverted = false; int ret; - if (cmd) + if (cmd != NULL) { /* Check if the command is preceded by "while" or "until" */ @@ -1791,7 +1791,7 @@ static int nsh_loop(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, /* Get the cmd following the "while" or "until" */ *ppcmd = nsh_argument(vtbl, saveptr, memlist); - if (!*ppcmd) + if (*ppcmd == NULL || **ppcmd == '\0') { nsh_output(vtbl, g_fmtarginvalid, cmd); goto errout; @@ -1806,7 +1806,7 @@ static int nsh_loop(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, /* Get the next cmd */ *ppcmd = nsh_argument(vtbl, saveptr, memlist); - if (!*ppcmd) + if (*ppcmd == NULL || **ppcmd == '\0') { nsh_output(vtbl, g_fmtarginvalid, cmd); goto errout; @@ -1983,7 +1983,7 @@ static int nsh_itef(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, bool disabled; bool inverted = false; - if (cmd) + if (cmd != NULL) { /* Check if the command is preceded by "if" */ @@ -1992,7 +1992,7 @@ static int nsh_itef(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, /* Get the cmd following the if */ *ppcmd = nsh_argument(vtbl, saveptr, memlist); - if (!*ppcmd) + if (*ppcmd == NULL || **ppcmd == '\0') { nsh_output(vtbl, g_fmtarginvalid, "if"); goto errout; @@ -2007,7 +2007,7 @@ static int nsh_itef(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, /* Get the next cmd */ *ppcmd = nsh_argument(vtbl, saveptr, memlist); - if (!*ppcmd) + if (*ppcmd == NULL || **ppcmd == '\0') { nsh_output(vtbl, g_fmtarginvalid, "if"); goto errout;