From dcb86b3580f73b9bcf147365473f7312d7e3502f Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 10 Nov 2021 20:03:20 +0800 Subject: [PATCH] fix errors checked by Address Sanitizer --- src/client/src/tscSubquery.c | 3 +++ src/client/src/tscUtil.c | 8 ++++---- src/common/src/tvariant.c | 2 +- src/tsdb/src/tsdbMeta.c | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index ad563454a5..b49fdbb97f 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -227,6 +227,7 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, STimeWindow * win) { if (skipped) { slot = 0; stackidx = 0; + tVariantDestroy(&tag); continue; } @@ -334,6 +335,7 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, STimeWindow * win) { } if (mergeDone) { + tVariantDestroy(&tag); break; } @@ -341,6 +343,7 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, STimeWindow * win) { stackidx = 0; skipRemainValue(mainCtx->p->pTSBuf, &tag); + tVariantDestroy(&tag); } stackidx = 0; diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 588853d999..55710c28d1 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -5414,7 +5414,7 @@ void getJsonTagValueAll(void* data, void* dst, int16_t bytes) { } int32_t length = 0; - if(!taosMbsToUcs4(json, strlen(json), varDataVal(tagData), bytes - VARSTR_HEADER_SIZE, &length)){ + if(!taosMbsToUcs4(json, strlen(json), varDataVal(tagData), bytes - VARSTR_HEADER_SIZE - CHAR_BYTES, &length)){ tscError("getJsonTagValueAll mbstoucs4 error! length:%d", length); } varDataSetLen(tagData, length); @@ -5589,11 +5589,11 @@ int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, in char *jsonValue = item->valuestring; strtrim(jsonValue); outLen = 0; - char tagVal[TSDB_MAX_JSON_TAGS_LEN + CHAR_BYTES] = {0}; + char tagVal[TSDB_MAX_JSON_TAGS_LEN] = {0}; *tagVal = jsonType2DbType(0, item->type); // type char* tagData = POINTER_SHIFT(tagVal,CHAR_BYTES); if (!taosMbsToUcs4(jsonValue, strlen(jsonValue), varDataVal(tagData), - TSDB_MAX_JSON_TAGS_LEN, &outLen)) { + TSDB_MAX_JSON_TAGS_LEN - CHAR_BYTES - VARSTR_HEADER_SIZE, &outLen)) { tscError("json string error:%s|%s", strerror(errno), jsonValue); retCode = tscSQLSyntaxErrMsg(errMsg, "serizelize json error", NULL); goto end; @@ -5675,4 +5675,4 @@ void* getJsonTagValue(STable* pTable, char* key, int32_t keyLen, int16_t* retCol return tdGetKVRowValOfCol(((STable*)(p->table))->tagVal, colId); } return NULL; -} \ No newline at end of file +} diff --git a/src/common/src/tvariant.c b/src/common/src/tvariant.c index 175a8174ab..511b03f65b 100644 --- a/src/common/src/tvariant.c +++ b/src/common/src/tvariant.c @@ -191,7 +191,7 @@ void tVariantCreateFromBinary(tVariant *pVar, const char *pz, size_t len, uint32 void tVariantDestroy(tVariant *pVar) { if (pVar == NULL) return; - if (pVar->nType == TSDB_DATA_TYPE_BINARY || pVar->nType == TSDB_DATA_TYPE_NCHAR) { + if (pVar->nType == TSDB_DATA_TYPE_BINARY || pVar->nType == TSDB_DATA_TYPE_NCHAR || pVar->nType == TSDB_DATA_TYPE_JSON) { tfree(pVar->pz); pVar->nLen = 0; } diff --git a/src/tsdb/src/tsdbMeta.c b/src/tsdb/src/tsdbMeta.c index 17abb2c3b8..9c2d86fe01 100644 --- a/src/tsdb/src/tsdbMeta.c +++ b/src/tsdb/src/tsdbMeta.c @@ -1179,7 +1179,7 @@ static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable) { int16_t nCols = kvRowNCols(pTable->tagVal); ASSERT(nCols%2 == 1); for (int j = 0; j < nCols; ++j) { - if (j != 0 && j != 2 && j%2 == 0) continue; // jump value + if (j != 0 && j%2 == 0) continue; // jump value SColIdx * pColIdx = kvRowColIdxAt(pTable->tagVal, j); void* val = (kvRowColVal(pTable->tagVal, pColIdx)); if (j == 0){ // json value is the first -- GitLab