diff --git a/source/common/src/tdataformat.c b/source/common/src/tdataformat.c index 4d231c82f3..3efccf23b4 100644 --- a/source/common/src/tdataformat.c +++ b/source/common/src/tdataformat.c @@ -2672,7 +2672,8 @@ static void (*tColDataGetValueImpl[])(SColData *pColData, int32_t iVal, SColVal tColDataGetValue7 // HAS_VALUE | HAS_NULL | HAS_NONE }; int32_t tColDataGetValue(SColData *pColData, int32_t iVal, SColVal *pColVal) { - if (iVal < 0 && iVal >= pColData->nVal || pColData->flag <= 0){ + if (iVal < 0 || iVal >= pColData->nVal || + (pColData->flag <= 0 || pColData->flag >= sizeof(tColDataGetValueImpl)/POINTER_BYTES)){ return TSDB_CODE_INVALID_PARA; } tColDataGetValueImpl[pColData->flag](pColData, iVal, pColVal); diff --git a/source/common/test/dataformatTest.cpp b/source/common/test/dataformatTest.cpp index ebf91025bb..a7c150c0ca 100644 --- a/source/common/test/dataformatTest.cpp +++ b/source/common/test/dataformatTest.cpp @@ -450,6 +450,19 @@ static void checkTSRow(const char **data, STSRow *row, STSchema *pTSchema) { } } +TEST(testCase, tColDataGetValue) { + SColData pColData = {0}; + SColVal pColVal = {0}; + ASSERT_NE(tColDataGetValue(&pColData, 0, &pColVal),0); + + pColData = {.flag = 8}; + pColVal = {0}; + ASSERT_NE(tColDataGetValue(&pColData, 0, &pColVal),0); + + pColData = {.nVal = 1, .flag = 8}; + ASSERT_NE(tColDataGetValue(&pColData, 0, &pColVal),0); +} + TEST(testCase, AllNormTest) { int16_t nCols = 14; STSRow *row = nullptr; diff --git a/source/dnode/vnode/src/meta/metaSnapshot.c b/source/dnode/vnode/src/meta/metaSnapshot.c index 30a20cd68d..8fe7d3823a 100644 --- a/source/dnode/vnode/src/meta/metaSnapshot.c +++ b/source/dnode/vnode/src/meta/metaSnapshot.c @@ -325,7 +325,6 @@ int32_t buildSnapContext(SVnode* pVnode, int64_t snapVersion, int64_t suid, int8 ctx->suidInfo = taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK); if (ctx->suidInfo == NULL) { return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY); - ; } taosHashSetFreeFp(ctx->suidInfo, destroySTableInfoForChildTable);