From ca26f550328e1e6fc9b0ab69a20c3c10929577da Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Tue, 6 Dec 2022 20:40:18 +0800 Subject: [PATCH] fix: memory leak --- source/libs/parser/src/parInsertSql.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/source/libs/parser/src/parInsertSql.c b/source/libs/parser/src/parInsertSql.c index bf23db5ec8..fa5fcacf06 100644 --- a/source/libs/parser/src/parInsertSql.c +++ b/source/libs/parser/src/parInsertSql.c @@ -1153,6 +1153,16 @@ static int32_t parseValueToken(SInsertParseContext* pCxt, const char** pSql, STo return code; } +static void clearColValArray(SArray* pCols) { + int32_t num = taosArrayGetSize(pCols); + for (int32_t i = 0; i < num; ++i) { + SColVal* pCol = taosArrayGet(pCols, i); + if (TSDB_DATA_TYPE_NCHAR == pCol->type) { + taosMemoryFreeClear(pCol->value.pData); + } + } +} + static int parseOneRow(SInsertParseContext* pCxt, const char** pSql, STableDataCxt* pTableCxt, bool* pGotRow, SToken* pToken) { SBoundColInfo* pCols = &pTableCxt->boundColsInfo; @@ -1206,6 +1216,8 @@ static int parseOneRow(SInsertParseContext* pCxt, const char** pSql, STableDataC *pGotRow = true; } + clearColValArray(pTableCxt->pValues); + return code; } -- GitLab