diff --git a/src/client/src/tscLocalMerge.c b/src/client/src/tscLocalMerge.c index d800d62c8a..44ccb2471a 100644 --- a/src/client/src/tscLocalMerge.c +++ b/src/client/src/tscLocalMerge.c @@ -510,7 +510,8 @@ void tscDestroyLocalReducer(SSqlObj *pSql) { taosTFree(pLocalReducer->pResultBuf); if (pLocalReducer->pResInfo != NULL) { - for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) { + size_t num = tscSqlExprNumOfExprs(pQueryInfo); + for (int32_t i = 0; i < num; ++i) { taosTFree(pLocalReducer->pResInfo[i].interResultBuf); } diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index d35fb21c57..1a8ed2e725 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -972,6 +972,8 @@ void tscFieldInfoClear(SFieldInfo* pFieldInfo) { } taosArrayDestroy(pFieldInfo->internalField); + taosTFree(pFieldInfo->final); + memset(pFieldInfo, 0, sizeof(SFieldInfo)); } @@ -1834,7 +1836,7 @@ static void doSetSqlExprAndResultFieldInfo(SQueryInfo* pQueryInfo, SQueryInfo* p return; } - // set the field info in pNewQueryInfo object + // set the field info in pNewQueryInfo object according to sqlExpr information size_t numOfExprs = tscSqlExprNumOfExprs(pNewQueryInfo); for (int32_t i = 0; i < numOfExprs; ++i) { SSqlExpr* pExpr = tscSqlExprGet(pNewQueryInfo, i);