fix a memory leak.

This commit is contained in:
hjxilinx 2020-02-02 13:51:49 +08:00
parent 2735c95624
commit c87c430515
1 changed files with 5 additions and 2 deletions

View File

@ -5994,10 +5994,13 @@ int32_t getDataBlocksForMeters(SMeterQuerySupportObj *pSupporter, SQuery *pQuery
size_t bufferSize = size + sizeof(TSCKSUM);
pMeterDataInfo[j]->numOfBlocks = compInfo.numOfBlocks;
pMeterDataInfo[j]->pBlock = calloc(1, bufferSize);
if (pMeterDataInfo[j]->pBlock == NULL) {
char* p = realloc(pMeterDataInfo[j]->pBlock, bufferSize);
if (p == NULL) {
clearAllMeterDataBlockInfo(pMeterDataInfo, 0, numOfMeters);
return TSDB_CODE_SERV_OUT_OF_MEMORY;
} else {
memset(p, 0, bufferSize);
pMeterDataInfo[j]->pBlock = (SCompBlock*) p;
}
read(pVnodeFileInfo->headerFd, pMeterDataInfo[j]->pBlock, bufferSize);