Fix regexTools.

The buildMatcher must not take a rvalue as it will keep a reference
to it.
This commit is contained in:
Matthieu Gautier 2019-08-12 12:04:58 +02:00
parent fee2da57e6
commit c4963268ba
1 changed files with 3 additions and 2 deletions

View File

@ -30,7 +30,7 @@
std::map<std::string, std::shared_ptr<icu::RegexPattern>> regexCache;
static pthread_mutex_t regexLock = PTHREAD_MUTEX_INITIALIZER;
std::unique_ptr<icu::RegexMatcher> buildMatcher(const std::string& regex, const icu::UnicodeString& content)
std::unique_ptr<icu::RegexMatcher> buildMatcher(const std::string& regex, icu::UnicodeString& content)
{
std::shared_ptr<icu::RegexPattern> pattern;
/* Regex is in cache */
@ -56,7 +56,8 @@ std::unique_ptr<icu::RegexMatcher> buildMatcher(const std::string& regex, const
bool matchRegex(const std::string& content, const std::string& regex)
{
ucnv_setDefaultName("UTF-8");
auto matcher = buildMatcher(regex, content.c_str());
icu::UnicodeString ucontent(content.c_str());
auto matcher = buildMatcher(regex, ucontent);
return matcher->find();
}