Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1a8a3f6

Browse files
committed
Fix regex match failures for backrefs combined with non-greedy quantifiers.
An ancient logic error in cfindloop() could cause the regex engine to failto find matches that begin later than the start of the string. Thisfunction 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 isnon-greedy (i.e. its first quantifier uses the ? modifier). Furthermore,the actual match must begin after some potential match that satisfies theDFA but then fails the back-reference's match test.Reported and fixed by Jeevan Chalke, with cosmetic adjustments by me.
1 parent5174bc2 commit1a8a3f6

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

‎src/backend/regex/regexec.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -464,19 +464,21 @@ cfindloop(struct vars * v,
464464
*coldp=cold;
465465
returner;
466466
}
467-
if ((shorter) ?end==estop :end==begin)
468-
{
469-
/* no point in trying again */
470-
*coldp=cold;
471-
returnREG_NOMATCH;
472-
}
473-
/* go around and try again */
467+
/* try next shorter/longer match with same begin point */
474468
if (shorter)
469+
{
470+
if (end==estop)
471+
break;/* NOTE BREAK OUT */
475472
estart=end+1;
473+
}
476474
else
475+
{
476+
if (end==begin)
477+
break;/* NOTE BREAK OUT */
477478
estop=end-1;
478-
}
479-
}
479+
}
480+
}/* end loop over endpoint positions */
481+
}/* end loop over beginning positions */
480482
}while (close<v->stop);
481483

482484
*coldp=cold;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp