From 19e4901e74fe29cdb11302873bd96641dd9b97da Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 13 Jun 2013 17:15:57 +0200 Subject: [PATCH] Fix for..in with duplicated properties Properties that already appeared earlier in the proto chain should get skipped by for..in (as they are inaccessible from JS). Change-Id: Ia0d9cc8582f96df4b2aaaa409d884f206456fe89 Reviewed-by: Simon Hausmann --- src/qml/qml/v4/qv4objectiterator.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/qml/qml/v4/qv4objectiterator.cpp b/src/qml/qml/v4/qv4objectiterator.cpp index 9c48ec7..984d470 100644 --- a/src/qml/qml/v4/qv4objectiterator.cpp +++ b/src/qml/qml/v4/qv4objectiterator.cpp @@ -65,9 +65,21 @@ Property *ObjectIterator::next(String **name, uint *index, PropertyAttributes *a if (!current) break; - p = current->advanceIterator(this, name, index, attrs); - if (p) + while (p = current->advanceIterator(this, name, index, attrs)) { + // check the property is not already defined earlier in the proto chain + if (current != object) { + Property *pp; + if (*name) { + pp = object->__getPropertyDescriptor__(*name); + } else { + assert (*index != UINT_MAX); + pp = object->__getPropertyDescriptor__(*index); + } + if (pp != p) + continue; + } return p; + } if (flags & WithProtoChain) current = current->prototype; -- 2.7.4