Skip to content

Commit

Permalink
Merge pull request #22868 from taosdata/fix/xsren/TS-3957/readLineOnW…
Browse files Browse the repository at this point in the history
…indows

free old pointer as realloc failed.
  • Loading branch information
gccgdb1234 committed Sep 12, 2023
2 parents e832908 + 51359ad commit 86c990d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions source/os/src/osFile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 86c990d

Please sign in to comment.