diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 89340f2b85..c5d19981cf 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -327,7 +327,8 @@ void addTagPseudoColumnData(SReadHandle *pHandle, SExprInfo* pPseudoExpr, int32_ for (int32_t i = 0; i < pBlock->info.rows; ++i) { colDataAppend(pColInfoData, i, data, (data == NULL)); } - if(pColInfoData->info.type != TSDB_DATA_TYPE_JSON && IS_VAR_DATA_TYPE(((const STagVal *)p)->type) && data){ + if(pColInfoData->info.type != TSDB_DATA_TYPE_JSON && p != NULL && + IS_VAR_DATA_TYPE(((const STagVal *)p)->type) && data){ taosMemoryFree(data); } } diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index 529e10be65..4cc3da5beb 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -2126,7 +2126,7 @@ static int32_t smlBuildTagRow(SArray* cols, SParsedDataColInfo* tags, SSchema* p val.nData = kv->length; }else if(pTagSchema->type == TSDB_DATA_TYPE_NCHAR){ int32_t output = 0; - void *p = taosMemoryCalloc(1, kv->length * TSDB_NCHAR_SIZE); + void *p = taosMemoryCalloc(1, pTagSchema->bytes - VARSTR_HEADER_SIZE); if(p == NULL){ code = TSDB_CODE_OUT_OF_MEMORY; goto end;