From 4f36b6bfbd16a40894ff3dec7e576fb4f87a7f98 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Tue, 16 Mar 2021 21:59:49 +0100 Subject: [PATCH] LibJS: Only set receiver value fallback once in Object::get() --- Userland/Libraries/LibJS/Runtime/Object.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp index 8951de17b9..f828219e76 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.cpp +++ b/Userland/Libraries/LibJS/Runtime/Object.cpp @@ -696,10 +696,11 @@ Value Object::get(const PropertyName& property_name, Value receiver) const return get_by_index(property_index); } + if (receiver.is_empty()) + receiver = Value(this); + const Object* object = this; while (object) { - if (receiver.is_empty()) - receiver = Value(const_cast(this)); auto value = object->get_own_property(property_name, receiver); if (vm().exception()) return {};