cppcheck mem leak

This commit is contained in:
iceman1001 2020-05-13 23:30:42 +02:00
parent 6a006677ef
commit 16f5107915

View file

@ -50,7 +50,10 @@ CMD *parse_command_line(const char *commandStr) {
// new memory size is default 20 for char **
int size = 20;
cmd->cmd = (char **) malloc(size * sizeof(char **));
if (!cmd->cmd) return NULL;
if (!cmd->cmd) {
free(cmd);
return NULL;
}
// parse
char *pStr = strtok(pTmp, " ");
cmd->cmd[0] = pStr;