Skip to content
Snippets Groups Projects
  • Tom Lane's avatar
    f1cb440d
    Fix regex match failures for backrefs combined with non-greedy quantifiers. · f1cb440d
    Tom Lane authored
    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.
    f1cb440d
    History
    Fix regex match failures for backrefs combined with non-greedy quantifiers.
    Tom Lane authored
    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.
regexec.c 32.33 KiB