diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 8066694709d35410d0872e2c98c9320649412c3f..556c4a9a1ff6e82491c17dedbb8938814b5ae103 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -3186,6 +3186,14 @@ typedef struct { int32_t tSerializeSBatchReq(void *buf, int32_t bufLen, SBatchReq *pReq); int32_t tDeserializeSBatchReq(void *buf, int32_t bufLen, SBatchReq *pReq); +static FORCE_INLINE void tFreeSBatchReqMsg(void* msg) { + if (NULL == msg) { + return; + } + SBatchMsg* pMsg = (SBatchMsg*)msg; + taosMemoryFree(pMsg->msg); +} + int32_t tSerializeSBatchRsp(void *buf, int32_t bufLen, SBatchRsp *pRsp); int32_t tDeserializeSBatchRsp(void *buf, int32_t bufLen, SBatchRsp *pRsp); diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 63a2b712fcc7503ac6b45dc2ce5cff97722e8ec2..52d9c5b1991001ecf25dc53465d64bdb14166a49 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -4510,7 +4510,7 @@ int32_t tDeserializeSBatchReq(void *buf, int32_t bufLen, SBatchReq *pReq) { if (tDecodeI32(&decoder, &msg.msgIdx) < 0) return -1; if (tDecodeI32(&decoder, &msg.msgType) < 0) return -1; if (tDecodeI32(&decoder, &msg.msgLen) < 0) return -1; - if (tDecodeBinary(&decoder, (uint8_t**)&msg.msg, NULL) < 0) return -1; + if (tDecodeBinaryAlloc(&decoder, &msg.msg, NULL) < 0) return -1; if (NULL == taosArrayPush(pReq->pMsgs, &msg)) return -1; } diff --git a/source/dnode/mnode/impl/src/mndQuery.c b/source/dnode/mnode/impl/src/mndQuery.c index b7a946d4e45f6bfd2408f72af6f7c6581f86f38d..5278fc776107c31e43375b16b708c0c8ad34901d 100644 --- a/source/dnode/mnode/impl/src/mndQuery.c +++ b/source/dnode/mnode/impl/src/mndQuery.c @@ -157,6 +157,7 @@ _exit: mError("mnd get batch meta failed cause of %s", tstrerror(code)); } + taosArrayDestroyEx(batchReq.pMsgs, tFreeSBatchReqMsg); taosArrayDestroyEx(batchRsp.pRsps, mnodeFreeSBatchRspMsg); return code; diff --git a/source/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c index 8d6ebe5c1472efccd965c907b006997b211b8cf4..8e9aab0afd129dbf1fab3d301d6da406590db3d2 100644 --- a/source/dnode/vnode/src/vnd/vnodeQuery.c +++ b/source/dnode/vnode/src/vnd/vnodeQuery.c @@ -366,6 +366,7 @@ _exit: qError("vnd get batch meta failed cause of %s", tstrerror(code)); } + taosArrayDestroyEx(batchReq.pMsgs, tFreeSBatchReqMsg); taosArrayDestroyEx(batchRsp.pRsps, tFreeSBatchRspMsg); tmsgSendRsp(&rspMsg);