commit 798c4a4d89ff7647e408ff93011d1f9ec79db949 Author: Daniel Swanson Date: Fri Jul 2 12:14:51 2021 -0500 delete RegexMatchers when we're done with them (memory leak) diff --git a/apertium/apertium_re.cc b/apertium/apertium_re.cc index 01599b3..c128abf 100644 --- a/apertium/apertium_re.cc +++ b/apertium/apertium_re.cc @@ -87,6 +87,7 @@ ApertiumRE::match(UString const &str) const } if (!m->find()) { + delete m; return ""_u; } @@ -97,6 +98,8 @@ ApertiumRE::match(UString const &str) const exit(EXIT_FAILURE); } + delete m; + return ret; } @@ -121,11 +124,13 @@ ApertiumRE::replace(UString &str, UString const &value) const // do this manually rather than call m->replaceFirst() // because we want to know that a match happened if (!m->find()) { + delete m; return false; } UString res = str.substr(0, m->start(err)); res.append(value); res.append(str.substr(m->end(err))); res.swap(str); + delete m; return true; }