From e30272bc4c71b31b2d7413a3015eb20d3b6c4100 Mon Sep 17 00:00:00 2001 From: yyuuttaaoo Date: Sat, 30 Dec 2023 01:00:21 +0000 Subject: [PATCH] fix: memory leak in ProcessorParseDelimiterNative Memeber mDelimiterModeFsmParserPtr is a raw pointer. It is not released in destructor. This patch fixed it by using a smart pointer instead. --- core/processor/ProcessorParseDelimiterNative.cpp | 2 +- core/processor/ProcessorParseDelimiterNative.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/processor/ProcessorParseDelimiterNative.cpp b/core/processor/ProcessorParseDelimiterNative.cpp index 5893ea6184..e0b26740be 100644 --- a/core/processor/ProcessorParseDelimiterNative.cpp +++ b/core/processor/ProcessorParseDelimiterNative.cpp @@ -58,7 +58,7 @@ bool ProcessorParseDelimiterNative::Init(const ComponentConfig& componentConfig) } } - mDelimiterModeFsmParserPtr = new DelimiterModeFsmParser(mQuote, mSeparatorChar); + mDelimiterModeFsmParserPtr.reset(new DelimiterModeFsmParser(mQuote, mSeparatorChar)); mParseFailures = &(GetContext().GetProcessProfile().parseFailures); mLogGroupSize = &(GetContext().GetProcessProfile().logGroupSize); diff --git a/core/processor/ProcessorParseDelimiterNative.h b/core/processor/ProcessorParseDelimiterNative.h index f218b6cc33..5606d0f81b 100644 --- a/core/processor/ProcessorParseDelimiterNative.h +++ b/core/processor/ProcessorParseDelimiterNative.h @@ -15,6 +15,7 @@ */ #include "plugin/interface/Processor.h" +#include #include #include #include "parser/DelimiterModeFsmParser.h" @@ -49,7 +50,7 @@ class ProcessorParseDelimiterNative : public Processor { bool mRawLogTagOverwritten = false; char mQuote; char mSeparatorChar; - DelimiterModeFsmParser* mDelimiterModeFsmParserPtr; + std::unique_ptr mDelimiterModeFsmParserPtr; int* mLogGroupSize = nullptr; int* mParseFailures = nullptr;