]> granicus.if.org Git - postgresql/commit
Fix regex match failures for backrefs combined with non-greedy quantifiers.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 19 Jul 2013 01:22:53 +0000 (21:22 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 19 Jul 2013 01:22:53 +0000 (21:22 -0400)
commitf4ceb7aa56e356da30a8de376a66f0fbcdbf938a
tree9d76e6ad216507812140a65a7adcfb0dacdca79d
parent2f397a08de49e28e3430ff7278f4648757dea2a3
Fix regex match failures for backrefs combined with non-greedy quantifiers.

An ancient logic error in cfindloop() could cause the regex engine to fail
to find matches that begin later than the start of the string.  This
function is only used when the regex pattern contains a back reference,
and so far as we can tell the error is only reachable if the pattern is
non-greedy (i.e. its first quantifier uses the ? modifier).  Furthermore,
the actual match must begin after some potential match that satisfies the
DFA but then fails the back-reference's match test.

Reported and fixed by Jeevan Chalke, with cosmetic adjustments by me.
src/backend/regex/regexec.c