diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-06-25 08:16:59 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-06-25 07:36:26 +0000 |
commit | 6f98978ef1a79da65dba8c5cf2c1d3d434c13690 (patch) | |
tree | c3ae5bb39309523f0b3b524ce8204fdd23189347 /src/qml/jsruntime/qv4identifiertable.cpp | |
parent | 3e1bb90da4c44455c8c307e01876cc2127bdb15c (diff) |
Fix a source of potential bugs in the Identifier table
Make sure we never add strings that represent array indices into
the identifier table.
Change-Id: Ib4a500d44b6ff58a71b7a55053c9be9f2580aea8
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4identifiertable.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4identifiertable.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4identifiertable.cpp b/src/qml/jsruntime/qv4identifiertable.cpp index c045ac3008..ee741e4abb 100644 --- a/src/qml/jsruntime/qv4identifiertable.cpp +++ b/src/qml/jsruntime/qv4identifiertable.cpp @@ -146,6 +146,12 @@ Heap::String *IdentifierTable::insertString(const QString &s) { uint subtype; uint hash = String::createHashValue(s.constData(), s.length(), &subtype); + if (subtype == Heap::String::StringType_ArrayIndex) { + Heap::String *str = engine->newString(s); + str->stringHash = hash; + str->subtype = subtype; + return str; + } uint idx = hash % alloc; while (Heap::StringOrSymbol *e = entriesByHash[idx]) { if (e->stringHash == hash && e->toQString() == s) |