Fix a small bug in queryIndexed() for StringObjects
authorLars Knoll <lars.knoll@digia.com>
Wed, 8 Jan 2014 13:57:07 +0000 (14:57 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Mon, 20 Jan 2014 20:13:54 +0000 (21:13 +0100)
The string is immutable, thus queries indexing into the
string data need to return Attr_NotWritable|Attr_NotConfigurable
(see 15.5.5.2 of the ecma spec).

Change-Id: I180d983b04a209c29fcd37b11682999b57bc42fe
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/qml/jsruntime/qv4object.cpp

index 0208c85..3b2fb09 100644 (file)
@@ -454,9 +454,9 @@ PropertyAttributes Object::queryIndexed(const Managed *m, uint index)
         return o->arrayData->attributes(index);
 
     if (o->isStringObject()) {
-        Property *p = static_cast<const StringObject *>(o)->getIndex(index);
-        if (p)
-            return Attr_Data;
+        String *s = static_cast<const StringObject *>(o)->value.asString();
+        if (index < (uint)s->length())
+            return (Attr_NotWritable|Attr_NotConfigurable);
     }
     return Attr_Invalid;
 }