From c5afbf547449cdf6122b94426e141a5d95f2fc6e Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Sat, 4 May 2024 21:09:25 +0800 Subject: [PATCH] fix: memory leak with cmd.command and buffer --- tools/shell/src/shellCommand.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/shell/src/shellCommand.c b/tools/shell/src/shellCommand.c index 265dc4530f..a160d2780c 100644 --- a/tools/shell/src/shellCommand.c +++ b/tools/shell/src/shellCommand.c @@ -488,6 +488,8 @@ int32_t shellReadCommand(char *command) { c = taosGetConsoleChar(); if (c == (char)EOF) { + taosMemoryFreeClear(cmd.buffer); + taosMemoryFreeClear(cmd.command); return c; } @@ -524,6 +526,8 @@ int32_t shellReadCommand(char *command) { case 4: // EOF or Ctrl+D taosResetTerminalMode(); printf("\r\n"); + taosMemoryFreeClear(cmd.buffer); + taosMemoryFreeClear(cmd.command); return -1; case 5: // ctrl E shellPositionCursorEnd(&cmd);