summaryrefslogtreecommitdiff
path: root/sql/item_strfunc.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mnogosearch.org>2014-11-10 16:43:27 +0400
committerAlexander Barkov <bar@mnogosearch.org>2014-11-10 16:43:27 +0400
commit9e8202013a8e0fc5e5693d8a08ab831d7ae49253 (patch)
tree219044ff1950c93ff961a92c967377fcd8f39864 /sql/item_strfunc.cc
parent080fdbf937cc01af61c141fb4e1918a3468948ea (diff)
downloadmariadb-git-9e8202013a8e0fc5e5693d8a08ab831d7ae49253.tar.gz
MDEV-6965 non-captured group \2 in regexp_replace
Diffstat (limited to 'sql/item_strfunc.cc')
-rw-r--r--sql/item_strfunc.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index f4629b6fc0f..339d053eade 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1379,12 +1379,15 @@ bool Item_func_regexp_replace::append_replacement(String *str,
break; /* End of line */
beg+= cnv;
- if ((n= ((int) wc) - '0') >= 0 && n <= 9 && n < re.nsubpatterns())
+ if ((n= ((int) wc) - '0') >= 0 && n <= 9)
{
- /* A valid sub-pattern reference found */
- int pbeg= re.subpattern_start(n), plength= re.subpattern_end(n) - pbeg;
- if (str->append(source->str + pbeg, plength, cs))
- return true;
+ if (n < re.nsubpatterns())
+ {
+ /* A valid sub-pattern reference found */
+ int pbeg= re.subpattern_start(n), plength= re.subpattern_end(n) - pbeg;
+ if (str->append(source->str + pbeg, plength, cs))
+ return true;
+ }
}
else
{