Fix StringObject::defineOwnProperty

* Check if this is an index property within the string length due to proxy object

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
This commit is contained in:
Seonghyun Kim 2026-04-29 18:20:40 +09:00 committed by MuHong Byun
commit 121d2fefca

View file

@ -77,6 +77,18 @@ ObjectGetResult StringObject::getOwnProperty(ExecutionState& state, const Object
bool StringObject::defineOwnProperty(ExecutionState& state, const ObjectPropertyName& P, const ObjectPropertyDescriptor& desc)
{
// Check if this is an index property within the string length
// String index properties are non-configurable and non-writable per ECMAScript spec
// We must reject any attempt to define a property on these indexed positions
size_t idx = P.tryToUseAsIndexProperty();
if (idx != Value::InvalidIndexPropertyValue) {
size_t strLen = m_primitiveValue->length();
if (idx < strLen) {
// Indexed properties within string length are non-configurable
// Per ECMAScript spec, defining a non-configurable property should fail
return false;
}
}
auto r = getOwnProperty(state, P);
if (r.hasValue() && !r.isConfigurable())
return false;