Fix infinite loop#63581
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses a parser/scanner hang triggered by certain JSDoc comment contents ending in -*/ (e.g. /**a-*/), by fixing operator-precedence in the identifier scanning loop so the pos < end guard correctly applies to both identifier-part scanning and the special - allowance.
Changes:
- Fixes the
whilecondition inscanJsDocTokensochar === CharacterCodes.minuscan’t keep the loop running afterposhas reachedend.
| if (isIdentifierStart(ch, languageVersion)) { | ||
| let char = ch; | ||
| while (pos < end && isIdentifierPart(char = codePointUnchecked(pos), languageVersion) || char === CharacterCodes.minus) pos += charSize(char); | ||
| while (pos < end && (isIdentifierPart(char = codePointUnchecked(pos), languageVersion) || char === CharacterCodes.minus)) pos += charSize(char); |
There was a problem hiding this comment.
+1, this needs a testcase
RyanCavanaugh
left a comment
There was a problem hiding this comment.
Please add a test. Thanks!
|
@microsoft-github-policy-service agree |
|
I'm going to merge this into main but I don't think we're going to do a patch release for just this one, given that it's not a 6.0 regression and is fixed in 7.0. If another critical issue (or handful of smaller ones) shows up we'll roll this into any future patch. Thanks! |
Fixes #63580