fix: memory leak when alter json tag to NULL

This commit is contained in:
kailixu 2024-03-15 16:31:01 +08:00
parent d02a125f34
commit dcbb92e817
2 changed files with 3 additions and 3 deletions

View File

@ -2820,7 +2820,7 @@ typedef struct {
char* tagName;
int8_t isNull;
int8_t tagType;
int8_t nullToken;
int8_t tagFree;
uint32_t nTagVal;
uint8_t* pTagVal;
SArray* pTagArray;

View File

@ -10443,7 +10443,7 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
code = parseTagValue(&pCxt->msgBuf, &tagStr, pTableMeta->tableInfo.precision, pSchema, &token, NULL,
pReq->pTagArray, &pTag);
if (pSchema->type == TSDB_DATA_TYPE_JSON && token.type == TK_NULL && code == TSDB_CODE_SUCCESS) {
pReq->nullToken = true;
pReq->tagFree = true;
}
}
if (TSDB_CODE_SUCCESS == code && tagStr) {
@ -10706,7 +10706,7 @@ static void destoryAlterTbReq(SVAlterTbReq* pReq) {
}
}
taosArrayDestroy(pReq->pTagArray);
if(pReq->nullToken) tTagFree((STag*)pReq->pTagVal);
if(pReq->tagFree) tTagFree((STag*)pReq->pTagVal);
}
static int32_t rewriteAlterTableImpl(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta,