From 5d23c595e67a58a6aa0bbecdd57bb3da6471acde Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Thu, 20 Oct 2022 09:34:36 +0800 Subject: [PATCH] fix(shell): coverity scan problem fixed add shellAuot.c --- src/kit/shell/src/shellAuto.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/kit/shell/src/shellAuto.c b/src/kit/shell/src/shellAuto.c index c39dac54a3..e56fb4594e 100644 --- a/src/kit/shell/src/shellAuto.c +++ b/src/kit/shell/src/shellAuto.c @@ -533,26 +533,16 @@ void parseCommand(SWords * command, bool pattern) { } // free Command -void freeCommand(SWords * command) { - SWord * word = command->head; - if (word == NULL) { - return ; - } - - // loop - while (word->next) { - SWord * tmp = word; - word = word->next; +void freeCommand(SWords* command) { + SWord* item = command->head; + // loop + while (item) { + SWord* tmp = item; + item = item->next; // if malloc need free - if(tmp->free && tmp->word) - free(tmp->word); - free(tmp); + if (tmp->free && tmp->word) taosMemoryFree(tmp->word); + taosMemoryFree(tmp); } - - // if malloc need free - if(word->free && word->word) - free(word->word); - free(word); } void GenerateVarType(int type, char** p, int count) { @@ -1178,11 +1168,11 @@ bool nextMatchCommand(TAOS * con, Command * cmd, SWords * firstMatch) { printScreen(con, cmd, match); // free + freeCommand(input); if (input->source) { free(input->source); input->source = NULL; } - freeCommand(input); free(input); return true; -- GitLab