From 983962238e34b5b6cba91b48cfe0725c57ab4f58 Mon Sep 17 00:00:00 2001 From: 54liuyao <54liuyao> Date: Mon, 2 Sep 2024 13:46:21 +0800 Subject: [PATCH] fix(query):fix query operator memory leak --- source/libs/executor/src/executil.c | 3 ++- source/libs/executor/src/executor.c | 2 ++ source/libs/executor/src/executorInt.c | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 757192b9b0..ea05ba6581 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -56,6 +56,7 @@ static int32_t getTableList(void* pVnode, SScanPhysiNode* pScanNode, SNode* pTag static int64_t getLimit(const SNode* pLimit) { return NULL == pLimit ? -1 : ((SLimitNode*)pLimit)->limit; } static int64_t getOffset(const SNode* pLimit) { return NULL == pLimit ? -1 : ((SLimitNode*)pLimit)->offset; } +static void releaseColInfoData(void* pCol); void initResultRowInfo(SResultRowInfo* pResultRowInfo) { pResultRowInfo->size = 0; @@ -531,7 +532,7 @@ static int32_t createResultData(SDataType* pType, int32_t numOfRows, SScalarPara int32_t code = colInfoDataEnsureCapacity(pColumnData, numOfRows, true); if (code != TSDB_CODE_SUCCESS) { terrno = code; - taosMemoryFree(pColumnData); + releaseColInfoData(pColumnData); return terrno; } diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index c13104fc07..65273487f6 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -1611,6 +1611,8 @@ int32_t getTableListInfo(const SExecTaskInfo* pTaskInfo, SArray** pList) { int32_t code = extractTableList(pArray, pTaskInfo->pRoot); if (code == 0) { *pList = pArray; + } else { + taosArrayDestroy(pArray); } return code; } diff --git a/source/libs/executor/src/executorInt.c b/source/libs/executor/src/executorInt.c index 42e7fbee1f..4b9e9cb02f 100644 --- a/source/libs/executor/src/executorInt.c +++ b/source/libs/executor/src/executorInt.c @@ -1105,7 +1105,8 @@ int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, SExecTaskInfo* SArray* pInfoList = NULL; int32_t code = getTableListInfo(pTask, &pInfoList); - if (code || pInfoList == NULL) { + if (code != TSDB_CODE_SUCCESS || pInfoList == NULL) { + taosMemoryFree(pDeleterParam); return code; }