diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2018-08-22 13:09:33 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-08-29 06:54:28 +0000 |
commit | ce1cd6468ad402003b7e7f3166c26485dd0bb9b1 (patch) | |
tree | de52cce3e4dabdcf9fdda3be61242c4ff6816dc3 /src/qml/jsruntime/qv4objectiterator.cpp | |
parent | 697564810f94ba32792ae714ca861e330bb4c657 (diff) |
Fix handling of uninitialized exports when iterating module namespace objects
We must throw reference errors when the iteration reaches an
uninitialized export.
As with other module namespace cases we don't know at the call site that
we're dealing with this special object, we must throw the reference
error inside the iterator. That brings in the additional complexity that
we can use the iterator to get a list of all names (should not throw) as
well as to retrieve the values (throw on uninit). We make the
distinction inside the ::next() function based on whether a Property
pointer was provided, which requires slightly different variants inside
the ObjectIterator that uses the internal iterator.
On the upside this avoids value copying when they would be unused
otherwise.
Change-Id: Iac45d0ed39bea861ea92db875821225c0feb9391
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4objectiterator.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4objectiterator.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4objectiterator.cpp b/src/qml/jsruntime/qv4objectiterator.cpp index 3d193455e9..8158d8ddd9 100644 --- a/src/qml/jsruntime/qv4objectiterator.cpp +++ b/src/qml/jsruntime/qv4objectiterator.cpp @@ -115,8 +115,7 @@ ReturnedValue ObjectIterator::nextPropertyNameAsString() PropertyAttributes attrs; Scope scope(engine); - ScopedProperty p(scope); - ScopedPropertyKey key(scope, next(p, &attrs)); + ScopedPropertyKey key(scope, next(nullptr, &attrs)); if (!key->isValid()) return Encode::null(); @@ -163,12 +162,13 @@ PropertyKey ForInIteratorObject::nextProperty() const Scope scope(this); ScopedObject c(scope, d()->current); ScopedObject o(scope); + ScopedProperty p(scope); ScopedPropertyKey key(scope); PropertyAttributes attrs; while (1) { while (1) { - key = d()->iterator->next(c, nullptr, &attrs); + key = d()->iterator->next(c, p, &attrs); if (!key->isValid()) break; if (!attrs.isEnumerable() || key->isSymbol()) |