1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:38:11 +00:00

LibJS: Disallow changing the prototype of non-extensible objects

Object::set_prototype() now returns a boolean indicating success.
Setting the prototype to an identical object is always considered
successful, even if the object is non-extensible.
This commit is contained in:
Linus Groh 2020-06-02 12:32:54 +01:00 committed by Andreas Kling
parent 8cf1ded478
commit b958e4f573
4 changed files with 22 additions and 6 deletions

View file

@ -112,7 +112,10 @@ Value ObjectConstructor::set_prototype_of(Interpreter& interpreter)
interpreter.throw_exception<TypeError>("Prototype must be null or object");
return {};
}
object->set_prototype(prototype);
if (!object->set_prototype(prototype)) {
interpreter.throw_exception<TypeError>("Can't set prototype of non-extensible object");
return {};
}
return object;
}