pgsql: Fix regex match failures for backrefs combined with non-greedy q - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Fix regex match failures for backrefs combined with non-greedy q
Date
Msg-id E1UzzQB-00032o-6q@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/e2bd904955e2221eddf01110b1f25002de2aaa83

Modified Files
--------------
src/backend/regex/regexec.c         |   20 +++++++++++---------
src/test/regress/expected/regex.out |   15 +++++++++++++++
src/test/regress/sql/regex.sql      |    5 +++++
3 files changed, 31 insertions(+), 9 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Fix regex match failures for backrefs combined with non-greedy q
Next
From: Tom Lane
Date:
Subject: pgsql: Fix regex match failures for backrefs combined with non-greedy q