This repository has been archived by the owner on Jan 13, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bounds for recursive calls to match from lookbehinds
Summary: When a lookbehind recursively calls `match`, the cursor direction is reversed. In this case, `remaining` returns the distance from the start of the string to the current position instead of the distance to the end of the string. When the cursor is at the end of the string, this leads to advanceStringIndex incorrectly being given a non-zero string length, and it then attempts to do an OOB read from the string. This problem could be solved equally well by conditioning the call to `advanceStringIndex` on whether `onlyAtStart` is true, but it is probably cleaner to just ensure that the length being passed is correct. (even if it is a little counterintuitive that advanceStringIndex is called at all while the cursor direction is reversed) The spec does not offer much guidance here since we effectively combine `@match` and `RegExpExec`. Reviewed By: avp Differential Revision: D23445121 fbshipit-source-id: 2341d20853083ff25376ac920cea27f220d91b21
- Loading branch information