free old pointer as realloc failed.
This commit is contained in:
parent
431d4380bf
commit
fe6f8d60f6
|
@ -840,8 +840,13 @@ int64_t taosGetLineFile(TdFilePtr pFile, char **__restrict ptrBuf) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bufferSize += 512;
|
bufferSize += 512;
|
||||||
*ptrBuf = taosMemoryRealloc(*ptrBuf, bufferSize);
|
void* newBuf = taosMemoryRealloc(*ptrBuf, bufferSize);
|
||||||
if (*ptrBuf == NULL) return -1;
|
if (newBuf == NULL) {
|
||||||
|
taosMemoryFreeClear(*ptrBuf);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
*ptrBuf = newBuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*ptrBuf)[totalBytesRead] = '\0';
|
(*ptrBuf)[totalBytesRead] = '\0';
|
||||||
|
|
Loading…
Reference in New Issue