Merge pull request #27574 from taosdata/fix/3.0/TD-31818

fix:[TD-31818] fix memory leak allocated by mode function.
This commit is contained in:
Pan Wei 2024-09-01 18:11:02 +08:00 committed by GitHub
commit 5c7506bfe0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 0 deletions

View File

@ -6007,6 +6007,7 @@ int32_t modeFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) {
pInfo->buf = taosMemoryMalloc(pInfo->colBytes);
if (NULL == pInfo->buf) {
taosHashCleanup(pInfo->pHash);
return TSDB_CODE_OUT_OF_MEMORY;
}
@ -6114,6 +6115,7 @@ int32_t modeFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId);
int32_t currentRow = pBlock->info.rows;
if (NULL == pCol) {
modeFunctionCleanup(pInfo);
return TSDB_CODE_OUT_OF_RANGE;
}
@ -6145,6 +6147,7 @@ int32_t modeFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
code = colDataSetVal(pCol, currentRow, pData, false);
if (TSDB_CODE_SUCCESS != code) {
modeFunctionCleanup(pInfo);
return code;
}
code = setSelectivityValue(pCtx, pBlock, &resTuplePos, currentRow);