diff --git a/source/client/src/clientJniConnector.c b/source/client/src/clientJniConnector.c index cfa6f84bd242199a332dbc3da8675dd18b0407cd..1658a0dd3259c6e03535d4b02f96d3f69e730fdf 100644 --- a/source/client/src/clientJniConnector.c +++ b/source/client/src/clientJniConnector.c @@ -581,8 +581,8 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchBlockImp(JNI return JNI_RESULT_SET_NULL; } - void *data; - int32_t numOfRows; + void *data = NULL; + int32_t numOfRows = 0; int error_code = taos_fetch_raw_block(tres, &numOfRows, &data); if (numOfRows == 0) { if (error_code == JNI_SUCCESS) { diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 5a3986257c53f969489af80f85e56c9496155c0e..416d3830b5095ac4d79ac1390f3a843ababf2df2 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -611,6 +611,9 @@ int taos_fetch_block_s(TAOS_RES *res, int *numOfRows, TAOS_ROW *rows) { } int taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData) { + *numOfRows = 0; + *pData = NULL; + if (res == NULL || TD_RES_TMQ_META(res)) { return 0; } diff --git a/source/client/src/clientTmqConnector.c b/source/client/src/clientTmqConnector.c index a8c9f2279d73f2cedf1c698d703c5591885a431e..894c51d13c9dd8e4205763893206de7ef86cdf7c 100644 --- a/source/client/src/clientTmqConnector.c +++ b/source/client/src/clientTmqConnector.c @@ -361,8 +361,8 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_fetchRawBlockImp( TAOS_RES *tres = (TAOS_RES *)res; - void *data; - int32_t numOfRows; + void *data = NULL; + int32_t numOfRows = 0; int error_code = taos_fetch_raw_block(tres, &numOfRows, &data); if (numOfRows == 0) { if (error_code == JNI_SUCCESS) { diff --git a/source/dnode/vnode/src/tsdb/tsdbCacheRead.c b/source/dnode/vnode/src/tsdb/tsdbCacheRead.c index e4c23c295a1b34cfc8649520e79b3cde7ff055d0..101b0291ceed453f23af7439a2501f04db15f78b 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCacheRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbCacheRead.c @@ -118,7 +118,6 @@ static int32_t setTableSchema(SCacheRowsReader* p, uint64_t suid, const char* id if (suid != 0) { p->pSchema = metaGetTbTSchema(p->pVnode->pMeta, suid, -1, 1); if (p->pSchema == NULL) { - taosMemoryFree(p); tsdbWarn("stable:%" PRIu64 " has been dropped, failed to retrieve cached rows, %s", suid, idstr); return TSDB_CODE_PAR_TABLE_NOT_EXIST; } diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 2766745cbe03641200a9cdfa7789d7ebfc776eb3..c939c115364901c449116e2a963948139d11bd45 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -390,8 +390,10 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, SBlockInfoBuf pUidList->tableUidList = taosMemoryMalloc(numOfTables * sizeof(uint64_t)); if (pUidList->tableUidList == NULL) { + taosHashCleanup(pTableMap); return NULL; } + pUidList->currentIndex = 0; for (int32_t j = 0; j < numOfTables; ++j) { @@ -4763,7 +4765,7 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa pTableBlockInfo->defMinRows = pc->minRows; pTableBlockInfo->defMaxRows = pc->maxRows; - int32_t bucketRange = ceil((pc->maxRows - pc->minRows) / numOfBucket); + int32_t bucketRange = ceil(((double)(pc->maxRows - pc->minRows)) / numOfBucket); pTableBlockInfo->numOfFiles += 1; diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 0ac458af495c8f4c3a3f4fd1ce7d982e5459aaf4..7390cc1d2652a692c8613538097ac857d5bd3b3c 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -820,6 +820,7 @@ static SSDataBlock* createTagValBlockForFilter(SArray* pColList, int32_t numOfTa int32_t code = blockDataEnsureCapacity(pResBlock, numOfTables); if (code != TSDB_CODE_SUCCESS) { terrno = code; + taosMemoryFree(pResBlock); return NULL; } diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 192b0cbc591a684e4ca4be2f7bd99923c5a9684d..3691a9255bbc9c38b62c0afb2eb813a957cfe016 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -2344,6 +2344,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo pOptr = createEventwindowOperatorInfo(ops[0], pPhyNode, pTaskInfo); } else { terrno = TSDB_CODE_INVALID_PARA; + taosMemoryFree(ops); return NULL; } diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c index a2dc202414cc64e337ae8dc44248753df1a6d1ad..3d9bacf39f3ea14e5e753d24dd618d6b53de0cbe 100644 --- a/source/libs/executor/src/groupoperator.c +++ b/source/libs/executor/src/groupoperator.c @@ -173,9 +173,14 @@ static void recordNewGroupKeys(SArray* pGroupCols, SArray* pGroupColVals, SSData size_t numOfGroupCols = taosArrayGetSize(pGroupCols); for (int32_t i = 0; i < numOfGroupCols; ++i) { - SColumn* pCol = taosArrayGet(pGroupCols, i); + SColumn* pCol = (SColumn*) taosArrayGet(pGroupCols, i); SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, pCol->slotId); + // valid range check. todo: return error code. + if (pCol->slotId > taosArrayGetSize(pBlock->pDataBlock)) { + continue; + } + if (pBlock->pBlockAgg != NULL) { pColAgg = pBlock->pBlockAgg[pCol->slotId]; // TODO is agg data matched? } diff --git a/source/libs/executor/src/tsort.c b/source/libs/executor/src/tsort.c index 6d734901ab3e43a165bdba05690abd222ff96385..291b0cf5155438a760ff7cbdf5dfe36cf5b79ea9 100644 --- a/source/libs/executor/src/tsort.c +++ b/source/libs/executor/src/tsort.c @@ -214,7 +214,6 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) { if (pPage == NULL) { taosArrayDestroy(pPageIdList); blockDataDestroy(p); - taosArrayDestroy(pPageIdList); return terrno; }