fix: shellReadHistory access invalid memory
This commit is contained in:
parent
09a04ed0a4
commit
2b5cf56556
|
@ -75,7 +75,7 @@ bool shellIsEmptyCommand(const char *cmd) {
|
||||||
|
|
||||||
int32_t shellRunSingleCommand(char *command) {
|
int32_t shellRunSingleCommand(char *command) {
|
||||||
shellCmdkilled = false;
|
shellCmdkilled = false;
|
||||||
|
|
||||||
if (shellIsEmptyCommand(command)) {
|
if (shellIsEmptyCommand(command)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1019,7 +1019,7 @@ void shellReadHistory() {
|
||||||
|
|
||||||
char *line = taosMemoryMalloc(TSDB_MAX_ALLOWED_SQL_LEN + 1);
|
char *line = taosMemoryMalloc(TSDB_MAX_ALLOWED_SQL_LEN + 1);
|
||||||
int32_t read_size = 0;
|
int32_t read_size = 0;
|
||||||
while ((read_size = taosGetsFile(pFile, TSDB_MAX_ALLOWED_SQL_LEN, line)) != -1) {
|
while ((read_size = taosGetsFile(pFile, TSDB_MAX_ALLOWED_SQL_LEN, line)) > 0) {
|
||||||
line[read_size - 1] = '\0';
|
line[read_size - 1] = '\0';
|
||||||
taosMemoryFree(pHistory->hist[pHistory->hend]);
|
taosMemoryFree(pHistory->hist[pHistory->hend]);
|
||||||
pHistory->hist[pHistory->hend] = taosStrdup(line);
|
pHistory->hist[pHistory->hend] = taosStrdup(line);
|
||||||
|
@ -1315,7 +1315,7 @@ int32_t shellExecute() {
|
||||||
shellSetConn(shell.conn, runOnce);
|
shellSetConn(shell.conn, runOnce);
|
||||||
shellReadHistory();
|
shellReadHistory();
|
||||||
|
|
||||||
if(shell.args.is_bi_mode) {
|
if(shell.args.is_bi_mode) {
|
||||||
// need set bi mode
|
// need set bi mode
|
||||||
printf("Set BI mode is true.\n");
|
printf("Set BI mode is true.\n");
|
||||||
#ifndef WEBSOCKET
|
#ifndef WEBSOCKET
|
||||||
|
|
Loading…
Reference in New Issue