1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:07:35 +00:00

LibJS: Check validity of computed_property_name() result before using it

This fixes two cases obj[expr] and obj[expr]() (MemberExpression and
CallExpression respectively) when expr throws an exception and results
in an empty value, causing a crash by passing the invalid PropertyName
created by computed_property_name() to Object::get() without checking it
first.

Fixes #3459.
This commit is contained in:
Linus Groh 2020-09-12 10:22:36 +01:00 committed by Andreas Kling
parent 75dac35d0e
commit 568d53c9b1
3 changed files with 17 additions and 3 deletions

View file

@ -0,0 +1,8 @@
test("Issue #3459, exception in computed property expression", () => {
expect(() => {
"foo"[bar];
}).toThrow(ReferenceError);
expect(() => {
"foo"[bar]();
}).toThrow(ReferenceError);
});