⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 276529 in webkit


Ignore:
Timestamp:
Apr 23, 2021, 4:38:34 PM (5 years ago)
Author:
Russell Epstein
Message:

Cherry-pick r276527. rdar://problem/77091667

[YARR Interpreter] Improper backtrack of parentheses with non-zero based greedy quantifiers
https://bugs.webkit.org/show_bug.cgi?id=224983

Reviewed by Mark Lam.

When we backtrack a parentheses with a greedy non zero based quantifier,
we don't properly restore for the case where we hadn't reached the minimum count.
We now save the input position on entry and restore it when we backtrack for
this case. We also properly release the allocated ParenthesesDisjunctionContext's.

  • yarr/YarrInterpreter.cpp: (JSC::Yarr::Interpreter::matchParentheses): (JSC::Yarr::Interpreter::backtrackParentheses):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276527 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-611-branch/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-611-branch/Source/JavaScriptCore/ChangeLog

    r276525 r276529  
     12021-04-23  Ruben Turcios  <rubent_22@apple.com>
     2
     3        Cherry-pick r276527. rdar://problem/77091667
     4
     5    [YARR Interpreter] Improper backtrack of parentheses with non-zero based greedy quantifiers
     6    https://bugs.webkit.org/show_bug.cgi?id=224983
     7   
     8    Reviewed by Mark Lam.
     9   
     10    When we backtrack a parentheses with a greedy non zero based quantifier,
     11    we don't properly restore for the case where we hadn't reached the minimum count.
     12    We now save the input position on entry and restore it when we backtrack for
     13    this case.  We also properly release the allocated ParenthesesDisjunctionContext's.
     14   
     15    * yarr/YarrInterpreter.cpp:
     16    (JSC::Yarr::Interpreter::matchParentheses):
     17    (JSC::Yarr::Interpreter::backtrackParentheses):
     18   
     19   
     20    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276527 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     21
     22    2021-04-23  Michael Saboff  <msaboff@apple.com>
     23
     24            [YARR Interpreter] Improper backtrack of parentheses with non-zero based greedy quantifiers
     25            https://bugs.webkit.org/show_bug.cgi?id=224983
     26
     27            Reviewed by Mark Lam.
     28
     29            When we backtrack a parentheses with a greedy non zero based quantifier,
     30            we don't properly restore for the case where we hadn't reached the minimum count.
     31            We now save the input position on entry and restore it when we backtrack for
     32            this case.  We also properly release the allocated ParenthesesDisjunctionContext's.
     33
     34            * yarr/YarrInterpreter.cpp:
     35            (JSC::Yarr::Interpreter::matchParentheses):
     36            (JSC::Yarr::Interpreter::backtrackParentheses):
     37
    1382021-04-23  Ruben Turcios  <rubent_22@apple.com>
    239
  • branches/safari-611-branch/Source/JavaScriptCore/yarr/YarrInterpreter.cpp

    r261755 r276529  
    4646
    4747    struct BackTrackInfoParentheses {
     48        uintptr_t begin;
    4849        uintptr_t matchAmount;
    4950        ParenthesesDisjunctionContext* lastContext;
     
    10161017        ByteDisjunction* disjunctionBody = term.atom.parenthesesDisjunction;
    10171018
     1019        backTrack->begin = input.getPos();
    10181020        backTrack->matchAmount = 0;
    10191021        backTrack->lastContext = nullptr;
     
    11691171                freeParenthesesDisjunctionContext(context);
    11701172
    1171                 if (result != JSRegExpNoMatch || backTrack->matchAmount < term.atom.quantityMinCount)
     1173                if (backTrack->matchAmount < term.atom.quantityMinCount) {
     1174                    while (backTrack->matchAmount) {
     1175                        context = backTrack->lastContext;
     1176                        resetMatches(term, context);
     1177                        popParenthesesDisjunctionContext(backTrack);
     1178                        freeParenthesesDisjunctionContext(context);
     1179                    }
     1180
     1181                    input.setPos(backTrack->begin);
     1182                    return result;
     1183                }
     1184
     1185                if (result != JSRegExpNoMatch)
    11721186                    return result;
    11731187            }
Note: See TracChangeset for help on using the changeset viewer.