fix: memory leak with cmd.command and buffer

This commit is contained in:
Alex Duan 2024-05-04 21:09:25 +08:00
parent 44100139a4
commit c5afbf5474
1 changed files with 4 additions and 0 deletions

View File

@ -488,6 +488,8 @@ int32_t shellReadCommand(char *command) {
c = taosGetConsoleChar(); c = taosGetConsoleChar();
if (c == (char)EOF) { if (c == (char)EOF) {
taosMemoryFreeClear(cmd.buffer);
taosMemoryFreeClear(cmd.command);
return c; return c;
} }
@ -524,6 +526,8 @@ int32_t shellReadCommand(char *command) {
case 4: // EOF or Ctrl+D case 4: // EOF or Ctrl+D
taosResetTerminalMode(); taosResetTerminalMode();
printf("\r\n"); printf("\r\n");
taosMemoryFreeClear(cmd.buffer);
taosMemoryFreeClear(cmd.command);
return -1; return -1;
case 5: // ctrl E case 5: // ctrl E
shellPositionCursorEnd(&cmd); shellPositionCursorEnd(&cmd);