diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 8066694709..556c4a9a1f 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 63a2b712fc..52d9c5b199 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 b7a946d4e4..5278fc7761 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 8d6ebe5c14..8e9aab0afd 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);