From 09883c77882534e2ccb262c748ab0d9d7cfdc2f0 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 27 Aug 2025 15:09:12 +0200 Subject: [PATCH] QtQml: Consistently check isReadOnly in QV4::Sequence MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We want generally want to throw an exception. Except in virtualMetaCall, since that would lead to cascading exceptions. There, just return 0 to notify the caller about the metaCall failure. Change-Id: Ie3970d01a5b433100f9722a2f12843abfe8d512a Reviewed-by: Olivier De Cannière --- src/qml/jsruntime/qv4sequenceobject.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index 7a357babe7..cfef4baf8b 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -373,8 +373,12 @@ bool Sequence::virtualDeleteProperty(Managed *that, PropertyKey id) Heap::Sequence *p = static_cast(that)->d(); - if (p->isReadOnly()) + if (p->isReadOnly()) { + p->internalClass->engine->throwTypeError( + QLatin1String("Cannot delete from a readonly container")); return false; + } + if (p->isReference() && !p->loadReference()) return false; @@ -444,6 +448,9 @@ int Sequence::virtualMetacall(Object *object, QMetaObject::Call call, int index, break; } case QMetaObject::WriteProperty: { + if (p->isReadOnly()) + return 0; + void *storagePointer = p->storagePointer(); const QMetaSequence metaSequence = p->metaSequence(); if (index < 0 || index >= metaSequence.size(storagePointer)) @@ -550,6 +557,8 @@ ReturnedValue SequencePrototype::method_shift( return ArrayPrototype::method_shift(b, thisObject, argv, argc); Heap::Sequence *p = s->d(); + if (p->isReadOnly()) + THROW_TYPE_ERROR(); if (p->isReference() && !p->loadReference()) RETURN_UNDEFINED();