Skip to content

Commit fb65429

Browse files
committed
csfilter: fix a memory leak in MsgReplace
1 parent d14695d commit fb65429

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

csfilter.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ inline std::string regexReplaceWrap(
4444
MsgFilter* MsgFilter::self_;
4545

4646
struct MsgReplace {
47-
const boost::regex *regex;
47+
const boost::regex regex;
4848
const std::string replaceWith;
4949

5050
MsgReplace(const std::string &regex_, const std::string &rpl) :
51-
regex(new boost::regex(regex_)),
51+
regex(regex_),
5252
replaceWith(rpl)
5353
{
5454
}
@@ -143,12 +143,12 @@ std::string MsgFilter::filterMsg(
143143
{
144144
std::string filtered = msg;
145145
BOOST_FOREACH(const struct MsgReplace *rpl, d->msgFilterMap[checker]) {
146-
filtered = regexReplaceWrap(filtered, *rpl->regex, rpl->replaceWith);
146+
filtered = regexReplaceWrap(filtered, rpl->regex, rpl->replaceWith);
147147
}
148148

149149
// these substitutions are common for all checkers
150150
BOOST_FOREACH(const struct MsgReplace *rpl, d->msgFilterMap[""]) {
151-
filtered = regexReplaceWrap(filtered, *rpl->regex, rpl->replaceWith);
151+
filtered = regexReplaceWrap(filtered, rpl->regex, rpl->replaceWith);
152152
}
153153

154154
#if DEBUG_SUBST > 1

0 commit comments

Comments
 (0)