fix:[TD-31909] Avoid double free when error occurs in mode function.

This commit is contained in:
Jing Sima 2024-09-05 17:25:31 +08:00
parent e07c85989d
commit ede112d39d
1 changed files with 2 additions and 0 deletions

View File

@ -6008,6 +6008,7 @@ int32_t modeFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) {
pInfo->buf = taosMemoryMalloc(pInfo->colBytes);
if (NULL == pInfo->buf) {
taosHashCleanup(pInfo->pHash);
pInfo->pHash = NULL;
return TSDB_CODE_OUT_OF_MEMORY;
}
@ -6016,6 +6017,7 @@ int32_t modeFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) {
static void modeFunctionCleanup(SModeInfo * pInfo) {
taosHashCleanup(pInfo->pHash);
pInfo->pHash = NULL;
taosMemoryFreeClear(pInfo->buf);
}