Merge pull request #22868 from taosdata/fix/xsren/TS-3957/readLineOnWindows

free old pointer as realloc failed.
This commit is contained in:
wade zhang 2023-09-12 18:52:18 +08:00 committed by GitHub
commit 86c990d33d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -862,8 +862,13 @@ int64_t taosGetLineFile(TdFilePtr pFile, char **__restrict ptrBuf) {
}
bufferSize += 512;
*ptrBuf = taosMemoryRealloc(*ptrBuf, bufferSize);
if (*ptrBuf == NULL) return -1;
void* newBuf = taosMemoryRealloc(*ptrBuf, bufferSize);
if (newBuf == NULL) {
taosMemoryFreeClear(*ptrBuf);
return -1;
}
*ptrBuf = newBuf;
}
(*ptrBuf)[totalBytesRead] = '\0';