From 0a118243ea9db85467673e4a70eca80dc5ebc6d5 Mon Sep 17 00:00:00 2001 From: xsren <285808407@qq.com> Date: Fri, 6 Sep 2024 09:38:23 +0800 Subject: [PATCH] fix: free invalid hash --- source/libs/function/src/builtinsimpl.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 2fa0cef5e8..1119ba576a 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -5996,10 +5996,6 @@ int32_t modeFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) { pInfo->colBytes = pCtx->resDataInfo.bytes; if (pInfo->pHash != NULL) { taosHashClear(pInfo->pHash); - pInfo->pHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); - if (NULL == pInfo->pHash) { - return terrno; - } } else { pInfo->pHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); if (NULL == pInfo->pHash) { @@ -6012,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; } @@ -6020,7 +6017,9 @@ int32_t modeFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) { static void modeFunctionCleanup(SModeInfo * pInfo) { taosHashCleanup(pInfo->pHash); + pInfo->pHash = NULL; taosMemoryFreeClear(pInfo->buf); + pInfo->buf = NULL; } void modeFunctionCleanupExt(SqlFunctionCtx* pCtx) {