fix: fix asan issues

This commit is contained in:
dapan1121 2022-11-17 16:31:22 +08:00
parent fb861a3935
commit 448fee1744
4 changed files with 11 additions and 1 deletions

View File

@ -3186,6 +3186,14 @@ typedef struct {
int32_t tSerializeSBatchReq(void *buf, int32_t bufLen, SBatchReq *pReq); int32_t tSerializeSBatchReq(void *buf, int32_t bufLen, SBatchReq *pReq);
int32_t tDeserializeSBatchReq(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 tSerializeSBatchRsp(void *buf, int32_t bufLen, SBatchRsp *pRsp);
int32_t tDeserializeSBatchRsp(void *buf, int32_t bufLen, SBatchRsp *pRsp); int32_t tDeserializeSBatchRsp(void *buf, int32_t bufLen, SBatchRsp *pRsp);

View File

@ -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.msgIdx) < 0) return -1;
if (tDecodeI32(&decoder, &msg.msgType) < 0) return -1; if (tDecodeI32(&decoder, &msg.msgType) < 0) return -1;
if (tDecodeI32(&decoder, &msg.msgLen) < 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; if (NULL == taosArrayPush(pReq->pMsgs, &msg)) return -1;
} }

View File

@ -157,6 +157,7 @@ _exit:
mError("mnd get batch meta failed cause of %s", tstrerror(code)); mError("mnd get batch meta failed cause of %s", tstrerror(code));
} }
taosArrayDestroyEx(batchReq.pMsgs, tFreeSBatchReqMsg);
taosArrayDestroyEx(batchRsp.pRsps, mnodeFreeSBatchRspMsg); taosArrayDestroyEx(batchRsp.pRsps, mnodeFreeSBatchRspMsg);
return code; return code;

View File

@ -366,6 +366,7 @@ _exit:
qError("vnd get batch meta failed cause of %s", tstrerror(code)); qError("vnd get batch meta failed cause of %s", tstrerror(code));
} }
taosArrayDestroyEx(batchReq.pMsgs, tFreeSBatchReqMsg);
taosArrayDestroyEx(batchRsp.pRsps, tFreeSBatchRspMsg); taosArrayDestroyEx(batchRsp.pRsps, tFreeSBatchRspMsg);
tmsgSendRsp(&rspMsg); tmsgSendRsp(&rspMsg);