diff --git a/include/util/tencode.h b/include/util/tencode.h index e318d4f2400065c3a8926c06f36c7d077fb5b45a..ad642cd612db4d1bb31f57b7a49d977e90978ee5 100644 --- a/include/util/tencode.h +++ b/include/util/tencode.h @@ -440,7 +440,7 @@ static FORCE_INLINE bool tDecodeIsEnd(SDecoder* pCoder) { return (pCoder->size = static FORCE_INLINE void* tEncoderMalloc(SEncoder* pCoder, int32_t size) { void* p = NULL; - SCoderMem* pMem = (SCoderMem*)taosMemoryMalloc(sizeof(*pMem) + size); + SCoderMem* pMem = (SCoderMem*)taosMemoryCalloc(1, sizeof(*pMem) + size); if (pMem) { pMem->next = pCoder->mList; pCoder->mList = pMem; @@ -451,7 +451,7 @@ static FORCE_INLINE void* tEncoderMalloc(SEncoder* pCoder, int32_t size) { static FORCE_INLINE void* tDecoderMalloc(SDecoder* pCoder, int32_t size) { void* p = NULL; - SCoderMem* pMem = (SCoderMem*)taosMemoryMalloc(sizeof(*pMem) + size); + SCoderMem* pMem = (SCoderMem*)taosMemoryCalloc(1, sizeof(*pMem) + size); if (pMem) { pMem->next = pCoder->mList; pCoder->mList = pMem; diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 714a17df0d94342440f9698cf4b32dcc87ad7982..9ebfa78b80d3e986c3b79a84f15e4b81032a465e 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -4984,8 +4984,10 @@ int tDecodeSVCreateTbReq(SDecoder *pCoder, SVCreateTbReq *pReq) { pReq->ctb.tagName = taosArrayInit(len, TSDB_COL_NAME_LEN); if(pReq->ctb.tagName == NULL) return -1; for (int32_t i = 0; i < len; i++){ - char *name = NULL; - if (tDecodeCStr(pCoder, &name) < 0) return -1; + char name[TSDB_COL_NAME_LEN] = {0}; + char *tmp = NULL; + if (tDecodeCStr(pCoder, &tmp) < 0) return -1; + strcpy(name, tmp); taosArrayPush(pReq->ctb.tagName, name); } } else if (pReq->type == TSDB_NORMAL_TABLE) { diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index d36947543790c7216c9d597cce4195269ddf2434..cca212a4e405dddedb9175677395ece6326bc5d8 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -494,8 +494,6 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pR taosArrayPush(rsp.pArray, &cRsp); } - tDecoderClear(&decoder); - tqUpdateTbUidList(pVnode->pTq, tbUids, true); tdUpdateTbUidList(pVnode->pSma, pStore); tdUidStoreFree(pStore); @@ -512,9 +510,12 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pR } tEncoderInit(&encoder, pRsp->pCont, pRsp->contLen); tEncodeSVCreateTbBatchRsp(&encoder, &rsp); - tEncoderClear(&encoder); _exit: + for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { + pCreateReq = req.pReqs + iReq; + taosArrayDestroy(pCreateReq->ctb.tagName); + } taosArrayDestroy(rsp.pArray); taosArrayDestroy(tbUids); tDecoderClear(&decoder); @@ -795,6 +796,7 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq if (tDecodeSVCreateTbReq(&decoder, &createTbReq) < 0) { pRsp->code = TSDB_CODE_INVALID_MSG; tDecoderClear(&decoder); + taosArrayDestroy(createTbReq.ctb.tagName); goto _exit; } @@ -802,6 +804,7 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq if (terrno != TSDB_CODE_TDB_TABLE_ALREADY_EXIST) { submitBlkRsp.code = terrno; tDecoderClear(&decoder); + taosArrayDestroy(createTbReq.ctb.tagName); goto _exit; } } @@ -822,6 +825,7 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq vnodeDebugPrintSingleSubmitMsg(pVnode->pMeta, pBlock, &msgIter, "real uid"); #endif tDecoderClear(&decoder); + taosArrayDestroy(createTbReq.ctb.tagName); } else { submitBlkRsp.tblFName = taosMemoryMalloc(TSDB_TABLE_FNAME_LEN); sprintf(submitBlkRsp.tblFName, "%s.", pVnode->config.dbname);