diff options
author | Linus Groh <mail@linusgroh.de> | 2020-11-04 09:48:48 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-11-04 15:31:39 +0100 |
commit | 41837f548df6f6cde6b798cf1421b2d2d1cabcfc (patch) | |
tree | 58202f0db051b3a657db7973fd1d607dcf4a466c /Libraries/LibJS/Tests | |
parent | 8afe1c81651f7d1690c84dab3d9e786b7ba9b166 (diff) | |
download | serenity-41837f548df6f6cde6b798cf1421b2d2d1cabcfc.zip |
LibJS: Don't create "valid" PropertyName from null string
When value.to_string() throws an exception it returns a null string in
which case we must not construct a valid PropertyName.
Also ASSERT in PropertyName(String) and PropertyName(FlyString) to
prevent this from happening in the future.
Fixes #3941.
Diffstat (limited to 'Libraries/LibJS/Tests')
-rw-r--r-- | Libraries/LibJS/Tests/computed-property-throws.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Libraries/LibJS/Tests/computed-property-throws.js b/Libraries/LibJS/Tests/computed-property-throws.js index 9c999c50e7..2f8e35eb63 100644 --- a/Libraries/LibJS/Tests/computed-property-throws.js +++ b/Libraries/LibJS/Tests/computed-property-throws.js @@ -6,3 +6,14 @@ test("Issue #3459, exception in computed property expression", () => { "foo"[bar](); }).toThrow(ReferenceError); }); + +test("Issue #3941, exception in computed property's toString()", () => { + expect(() => { + const o = { + toString() { + throw Error(); + }, + }; + "foo"[o]; + }).toThrow(Error); +}); |