Fix crash in parseJsxChild found by fuzzing (#53674)

This commit is contained in:
Jake Bailey 2023-04-05 13:47:02 -07:00 committed by GitHub
parent bebb6d0086
commit f243b987af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 48 additions and 1 deletions

View File

@ -6013,7 +6013,7 @@ namespace Parser {
// We want the error span to cover only 'Foo.Bar' in < Foo.Bar >
// or to cover only 'Foo' in < Foo >
const tag = openingTag.tagName;
const start = skipTrivia(sourceText, tag.pos);
const start = Math.min(skipTrivia(sourceText, tag.pos), tag.end);
parseErrorAt(start, tag.end, Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, getTextOfNodeFromSourceText(sourceText, openingTag.tagName));
}
return undefined;

View File

@ -0,0 +1,18 @@
tests/cases/compiler/a.js(1,3): error TS17008: JSX element '' has no corresponding closing tag.
tests/cases/compiler/a.js(1,4): error TS1003: Identifier expected.
tests/cases/compiler/a.js(1,5): error TS1005: '...' expected.
tests/cases/compiler/a.js(3,1): error TS1005: '</' expected.
==== tests/cases/compiler/a.js (4 errors) ====
!< {:>
!!! error TS17008: JSX element '' has no corresponding closing tag.
~
!!! error TS1003: Identifier expected.
~
!!! error TS1005: '...' expected.
!!! error TS1005: '</' expected.

View File

@ -0,0 +1,9 @@
//// [a.js]
!< {:>
//// [a.js]
!< {...}>
</>;

View File

@ -0,0 +1,5 @@
=== tests/cases/compiler/a.js ===
!< {:>

View File

@ -0,0 +1,10 @@
=== tests/cases/compiler/a.js ===
!< {:>
>!< {:> : boolean
>< {:> : any
> : any
> : any
> : any

View File

@ -0,0 +1,5 @@
// @allowJs: true
// @outDir: ./out
// @filename: a.js
!< {:>