Skip to content
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

OutOfMemoryError in TokenStream#readTemplateLiteral #1337

Closed
katherine-hough opened this issue Jun 8, 2023 · 1 comment
Closed

OutOfMemoryError in TokenStream#readTemplateLiteral #1337

katherine-hough opened this issue Jun 8, 2023 · 1 comment
Assignees

Comments

@katherine-hough
Copy link

Rhino Version: 1.7.14
Java Version: OpenJDK 11.0.19

Missing EOF check in TokenStream#readTemplateLiteral causes OutOfMemoryError when parsing a malformed Unicode code point escape in a template literal. The for loop on line 1609 of TokenStream:

repeats until an OutOfMemoryError is raised because neither a } nor a ` character is encountered before the end of the input.

Input:

`\u{8

Expected Output: A syntax error

Actual Output:

java.lang.OutOfMemoryError: Java heap space
        at java.util.Arrays.copyOf(Arrays.java:3332)
        at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:124)
        at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:649)
        at java.lang.StringBuilder.append(StringBuilder.java:202)
        at org.mozilla.javascript.TokenStream.getTemplateLiteralChar(TokenStream.java:1480)
        at org.mozilla.javascript.TokenStream.peekTemplateLiteralChar(TokenStream.java:1499)
        at org.mozilla.javascript.TokenStream.readTemplateLiteral(TokenStream.java:1610)
@rbri rbri self-assigned this Jun 8, 2023
@rbri
Copy link
Collaborator

rbri commented Jun 8, 2023

Will have a look....

rbri added a commit to rbri/rhino that referenced this issue Jun 8, 2023
rbri added a commit to rbri/rhino that referenced this issue Jun 8, 2023
rbri added a commit to rbri/rhino that referenced this issue Jun 8, 2023
@gbrail gbrail closed this as completed in 75ac003 Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants