mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 12:35:14 +00:00
LibJS: Cache length identifier for GetLengthWithThis
We cached the length identifier for GetLength, but not GetLengthWithThis. This caused an `has_value()` verification failure when accessing super.length. Found by Fuzzilli.
This commit is contained in:
parent
408f9f3dde
commit
4cd4d0625b
2 changed files with 23 additions and 0 deletions
|
@ -1116,6 +1116,7 @@ void Generator::emit_get_by_id(ScopedOperand dst, ScopedOperand base, Identifier
|
|||
void Generator::emit_get_by_id_with_this(ScopedOperand dst, ScopedOperand base, IdentifierTableIndex id, ScopedOperand this_value)
|
||||
{
|
||||
if (m_identifier_table->get(id) == "length"sv) {
|
||||
m_length_identifier = id;
|
||||
emit<Op::GetLengthWithThis>(dst, base, this_value, m_next_property_lookup_cache++);
|
||||
return;
|
||||
}
|
||||
|
|
22
Libraries/LibJS/Tests/regress/super-length-crash.js
Normal file
22
Libraries/LibJS/Tests/regress/super-length-crash.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
test("does not crash when accessing super.length", () => {
|
||||
let result;
|
||||
|
||||
class A {
|
||||
constructor() {}
|
||||
|
||||
get length() {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
constructor() {
|
||||
super();
|
||||
result = super.length;
|
||||
}
|
||||
}
|
||||
|
||||
new B();
|
||||
|
||||
expect(result).toBe(2);
|
||||
});
|
Loading…
Add table
Reference in a new issue