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

Commitf4ceb7a

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 parent2f397a0 commitf4ceb7a

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
@@ -467,19 +467,21 @@ cfindloop(struct vars * v,
467467
*coldp=cold;
468468
returner;
469469
}
470-
if ((shorter) ?end==estop :end==begin)
471-
{
472-
/* no point in trying again */
473-
*coldp=cold;
474-
returnREG_NOMATCH;
475-
}
476-
/* go around and try again */
470+
/* try next shorter/longer match with same begin point */
477471
if (shorter)
472+
{
473+
if (end==estop)
474+
break;/* NOTE BREAK OUT */
478475
estart=end+1;
476+
}
479477
else
478+
{
479+
if (end==begin)
480+
break;/* NOTE BREAK OUT */
480481
estop=end-1;
481-
}
482-
}
482+
}
483+
}/* end loop over endpoint positions */
484+
}/* end loop over beginning positions */
483485
}while (close<v->stop);
484486

485487
*coldp=cold;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp