From b9d8f63e859c4c238c5cbe79438f6026d981a3f8 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Thu, 30 May 2024 16:28:51 +0800 Subject: [PATCH 1/2] 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) { From 1821f9aae402577dda7891a3132dc29a89320343 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Thu, 30 May 2024 16:29:31 +0800 Subject: [PATCH 2/2] format --- source/common/src/tmsg.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index de24e7047b..c6cf5d1037 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -5630,6 +5630,7 @@ int32_t tDeserializeSVKillCompactReq(void *buf, int32_t bufLen, SVKillCompactReq code = TSDB_CODE_MSG_DECODE_ERROR; goto _exit; } + if (tDecodeI32(&decoder, &pReq->vgId) < 0) { code = TSDB_CODE_MSG_DECODE_ERROR; goto _exit;