Skip to content

Conversation

chqrlie
Copy link
Collaborator

@chqrlie chqrlie commented May 14, 2024

  • output more informative error messages in js_parse_expect.

The previous code was bogus:

    return js_parse_error(s, "expecting '%c'", tok);

this was causing a bug on eval("do;") where tok is TOK_WHILE (-70, 0xBA) creating an invalid UTF-8 encoding (lone trailing byte). This would ultimately have caused a failure in JS_ThrowError2 if JS_NewString failed when converting an error to a string if the conversion detects invalid UTF-8 encoding and throws an error (it currently does not, but should).

  • test for JS_NewString failure in JS_ThrowError2
  • test for JS_FreeCString failure in run-test262.c
  • add more test cases

- output more informative error messages in `js_parse_expect`.

The previous code was bogus:
```
    return js_parse_error(s, "expecting '%c'", tok);
```
this was causing a bug on `eval("do;")` where `tok` is `TOK_WHILE` (-70, 0xBA)
creating an invalid UTF-8 encoding (lone trailing byte).
This would ultimately have caused a failure in `JS_ThrowError2` if `JS_NewString`
failed when converting an error to a string if the conversion detects invalid
UTF-8 encoding and throws an error (it currently does not, but should).

- test for `JS_NewString` failure in `JS_ThrowError2`
- test for `JS_FreeCString` failure in run-test262.c
- add more test cases
@chqrlie chqrlie merged commit 5a7e578 into quickjs-ng:master May 14, 2024
@chqrlie chqrlie deleted the fix-parse-expect branch May 14, 2024 18:36
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

Successfully merging this pull request may close these issues.

2 participants