• Jakob Gruber's avatar
    [regexp] Fix sticky callable replace with OOB lastIndex · dd580e8f
    Jakob Gruber authored
    When given a sticky regexp s.t. lastIndex > subject.length, the
    following should happen:
    
    1. exec returns null (= no match)
    2. lastIndex is reset to 0.
    
    This is usually done by the RegExp.p.exec builtin; but in some cases
    we take different paths and try to re-implement the parts of exec that
    we need.
    
    One of these cases was in %StringReplaceNonGlobalRegExpWithFunction.
    Here, we set lastIndex to 0 but then incorrectly called into
    RegExpImpl::Exec. REI::Exec started matching with lastIndex == 0,
    which is just plain wrong. With this CL we now correctly omit the
    REI::Exec call and return null.
    
    Bug: chromium:937681, v8:5361
    Change-Id: I6bb1114a6b92ed3c6e63ec7f6ec2df4b95a19b4c
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1514679Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
    Commit-Queue: Jakob Gruber <jgruber@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#60169}
    dd580e8f
runtime-regexp.cc 66.5 KB