From 21f8d6b7c1d5a5a6d35bd9f41baaa9e564c3b8c9 Mon Sep 17 00:00:00 2001 From: Shungang Li Date: Mon, 12 Aug 2024 14:26:02 +0800 Subject: [PATCH] fix: memleak in taosSplitS3Cfg --- source/common/src/cos.c | 6 +++++- source/common/src/tglobal.c | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/source/common/src/cos.c b/source/common/src/cos.c index 7fa390d3bb..8312d02bff 100644 --- a/source/common/src/cos.c +++ b/source/common/src/cos.c @@ -955,7 +955,11 @@ static int32_t s3InitEpIndexArray(SArray **pIndexArray) { } for (int8_t i = 0; i < tsS3EpNum; ++i) { - taosArraySet(indexArray, i, &i); + if (taosArrayPush(indexArray, &i) == NULL) { + taosArrayDestroy(indexArray); + uError("%s: %s", __func__, "out of memory"); + TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY); + } } if (tsS3EpNum > 1) { diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index e3048bcecf..4e32288123 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -376,6 +376,7 @@ static int32_t taosSplitS3Cfg(SConfig *pCfg, const char *name, char gVarible[TSD *pNum = num; _exit: + taosMemoryFreeClear(slices); taosMemoryFreeClear(strDup); TAOS_RETURN(code); }