From e618370cdbd56a05dfc1da7c89b90022018d170c Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Thu, 22 Sep 2016 23:50:07 +0300 Subject: [PATCH] MXS-875: Fix regexfilter matching The return values of pcre2_match are now properly handled. A positive match is a return value which is greater than or equal to zero. This fix should give a small performance boost to as memory is no longer needlessly allocated. --- server/modules/filter/regexfilter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/modules/filter/regexfilter.c b/server/modules/filter/regexfilter.c index 65802d83b..4d12ee560 100644 --- a/server/modules/filter/regexfilter.c +++ b/server/modules/filter/regexfilter.c @@ -482,7 +482,7 @@ regex_replace(const char *sql, pcre2_code *re, pcre2_match_data *match_data, con size_t result_size; /** This should never fail with rc == 0 because we used pcre2_match_data_create_from_pattern() */ - if (pcre2_match(re, (PCRE2_SPTR) sql, PCRE2_ZERO_TERMINATED, 0, 0, match_data, NULL)) + if (pcre2_match(re, (PCRE2_SPTR) sql, PCRE2_ZERO_TERMINATED, 0, 0, match_data, NULL) > 0) { result_size = strlen(sql) + strlen(replace); result = malloc(result_size);