Skip to content

Fix crash in parseJsxChild found by fuzzing #53674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6011,7 +6011,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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//// [a.js]
!< {:>



//// [a.js]
!< {...}>

</>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
=== tests/cases/compiler/a.js ===

!< {:>


Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
=== tests/cases/compiler/a.js ===
!< {:>
>!< {:> : boolean
>< {:> : any
> : any
> : any


> : any

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @allowJs: true
// @outDir: ./out
// @filename: a.js
!< {:>