diff options
Diffstat (limited to 'avr/cli.c')
-rw-r--r-- | avr/cli.c | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -181,11 +181,11 @@ static int cli_run_command(const char *cmd, int flag) if (!cmd || !*cmd) return -1; /* empty command */ - - cmdbuf = xmalloc(strlen(cmd) + 1); finaltoken = xmalloc(CONFIG_SYS_CBSIZE); + cmdbuf = strdup(cmd); + if (!cmdbuf) + return -1; /* not enough memory */ - strcpy(cmdbuf, cmd); str = cmdbuf; /* Process separators and check for invalid @@ -309,11 +309,8 @@ void cli_loop(void) flag = 0; /* assume no special flags for now */ if (len > 0) { - lastcommand = (char *) xrealloc(lastcommand, len+1); - if (lastcommand != NULL) { - strncpy(lastcommand, console_buffer, len+1); - lastcommand[len] = '\0'; - } + free (lastcommand); + lastcommand = strdup(console_buffer); } else if (len == 0) flag |= CMD_FLAG_REPEAT; |