From b9d8f63e859c4c238c5cbe79438f6026d981a3f8 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Thu, 30 May 2024 16:28:51 +0800 Subject: [PATCH] fix: memory leak --- source/common/src/tmsg.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index ef37a41fcf..de24e7047b 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -5616,18 +5616,35 @@ int32_t tSerializeSVKillCompactReq(void *buf, int32_t bufLen, SVKillCompactReq * } int32_t tDeserializeSVKillCompactReq(void *buf, int32_t bufLen, SVKillCompactReq *pReq) { + int32_t code = 0; SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); - if (tStartDecode(&decoder) < 0) return -1; + if (tStartDecode(&decoder) < 0) { + code = TSDB_CODE_MSG_DECODE_ERROR; + goto _exit; + } - if (tDecodeI32(&decoder, &pReq->compactId) < 0) return -1; - if (tDecodeI32(&decoder, &pReq->vgId) < 0) return -1; - if (tDecodeI32(&decoder, &pReq->dnodeId) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->compactId) < 0) { + code = TSDB_CODE_MSG_DECODE_ERROR; + goto _exit; + } + if (tDecodeI32(&decoder, &pReq->vgId) < 0) { + code = TSDB_CODE_MSG_DECODE_ERROR; + goto _exit; + } + + if (tDecodeI32(&decoder, &pReq->dnodeId) < 0) { + code = TSDB_CODE_MSG_DECODE_ERROR; + goto _exit; + } tEndDecode(&decoder); + +_exit: tDecoderClear(&decoder); - return 0; + return code; } int32_t tSerializeSAlterVnodeConfigReq(void *buf, int32_t bufLen, SAlterVnodeConfigReq *pReq) {