From 8462669d278b2cabe07648b3399c77834a3c485e Mon Sep 17 00:00:00 2001 From: Stijn Kliemesch Date: Fri, 8 Nov 2019 09:08:01 +0100 Subject: [PATCH] Fix for #616 Affects strict mode only. No longer prematurely throws a TypeError in ScriptableObject.putImpl(Object,int,Scriptable,Object) when instance member isExtensible is false. Instead, now it first queries the slotmap, so that if a GetterSlot instance is returned, any present setter may be called. All other outcomes of this method should be unaffected. --- src/org/mozilla/javascript/ScriptableObject.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/org/mozilla/javascript/ScriptableObject.java b/src/org/mozilla/javascript/ScriptableObject.java index bd23ccd1f6..e9be363686 100644 --- a/src/org/mozilla/javascript/ScriptableObject.java +++ b/src/org/mozilla/javascript/ScriptableObject.java @@ -2804,20 +2804,18 @@ private boolean putImpl(Object key, int index, Scriptable start, { // This method is very hot (basically called on each assignment) // so we inline the extensible/sealed checks below. - if (!isExtensible) { - Context cx = Context.getContext(); - if (cx.isStrictMode()) { - throw ScriptRuntime.typeError0("msg.not.extensible"); - } - } Slot slot; if (this != start) { slot = slotMap.query(key, index); + if(!isExtensible && Context.getContext().isStrictMode() && (slot == null || !(slot instanceof GetterSlot))) + throw ScriptRuntime.typeError0("msg.not.extensible"); if (slot == null) { return false; } } else if (!isExtensible) { slot = slotMap.query(key, index); + if(Context.getContext().isStrictMode() && (slot == null || !(slot instanceof GetterSlot))) + throw ScriptRuntime.typeError0("msg.not.extensible"); if (slot == null) { return true; }