From 623eadb44e9c5a77bef963d572040e22da4f48db Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Wed, 16 Jun 2021 20:41:29 +0300 Subject: [PATCH] LibJS: Stop overwriting existing indexed accessors in define_accessor The previous implementation only checked the shape, ignoring existing accessors when using number property names. --- Userland/Libraries/LibJS/Runtime/Object.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp index e2795a3d9f..9fc6c53b71 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.cpp +++ b/Userland/Libraries/LibJS/Runtime/Object.cpp @@ -591,13 +591,8 @@ bool Object::define_accessor(const PropertyName& property_name, Function* getter { VERIFY(property_name.is_valid()); - Accessor* accessor { nullptr }; - auto property_metadata = shape().lookup(property_name.to_string_or_symbol()); - if (property_metadata.has_value()) { - auto existing_property = get_direct(property_metadata.value().offset); - if (existing_property.is_accessor()) - accessor = &existing_property.as_accessor(); - } + auto existing_property = get_own_property(property_name, this, true); + auto* accessor = existing_property.is_accessor() ? &existing_property.as_accessor() : nullptr; if (!accessor) { accessor = Accessor::create(vm(), getter, setter); bool definition_success = define_property(property_name, accessor, attributes, throw_exceptions);