QmlJS: Avoid infinite loop with recursive prototypes.

This commit is contained in:
Christian Kamm
2010-11-12 14:53:00 +01:00
parent 443be8eea6
commit f7a077b1fa
8 changed files with 135 additions and 47 deletions

View File

@@ -71,12 +71,16 @@ static const ObjectValue *prototypeWithMember(const Context *context, const Obje
const Value *value = object->property(name, context);
if (!value)
return 0;
forever {
const ObjectValue *prototype = object->prototype(context);
if (!prototype || prototype->property(name, context) != value)
return object;
object = prototype;
const ObjectValue *prev = object;
PrototypeIterator iter(object, context);
iter.next();
while (iter.hasNext()) {
const ObjectValue *prototype = iter.next();
if (prototype->property(name, context) != value)
return prev;
prev = prototype;
}
return prev;
}
namespace {