Merge pull request #18748 from taosdata/refact/submit_req_wxy

fix: memory leak
This commit is contained in:
Xiaoyu Wang 2022-12-06 20:41:11 +08:00 committed by GitHub
commit ada9d1a360
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions

View File

@ -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;
}