Merge pull request #24930 from taosdata/fix/TD-28901
fix: shellReadHistory access invalid memory
This commit is contained in:
commit
557e6018e2
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue