Skip to content

Commit 9bae436

Browse files
committed
Avoid setting cyclic prototype in BaseFunction.construct().
Fixes bug 760973 - Object(Object.prototype) causes an infinite loop
1 parent 5259780 commit 9bae436

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/org/mozilla/javascript/BaseFunction.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,10 @@ public Scriptable construct(Context cx, Scriptable scope, Object[] args)
385385
}
386386
result = (Scriptable)val;
387387
if (result.getPrototype() == null) {
388-
result.setPrototype(getClassPrototype());
388+
Scriptable proto = getClassPrototype();
389+
if (result != proto) {
390+
result.setPrototype(proto);
391+
}
389392
}
390393
if (result.getParentScope() == null) {
391394
Scriptable parent = getParentScope();

0 commit comments

Comments
 (0)