Title: [209020] trunk/Source
Revision
209020
Author
[email protected]
Date
2016-11-28 14:29:39 -0800 (Mon, 28 Nov 2016)

Log Message

Fix exception scope verification failures in ObjectConstructor.cpp and ObjectPrototype.cpp.
https://bugs.webkit.org/show_bug.cgi?id=165051

Reviewed by Saam Barati.

Source/_javascript_Core:

Also,
1. Replaced returning JSValue() with returning { }.
2. Replaced uses of exec->propertyNames() with vm.propertyNames.

* runtime/ObjectConstructor.cpp:
(JSC::constructObject):
(JSC::objectConstructorGetPrototypeOf):
(JSC::objectConstructorGetOwnPropertyDescriptor):
(JSC::objectConstructorGetOwnPropertyDescriptors):
(JSC::objectConstructorGetOwnPropertyNames):
(JSC::objectConstructorGetOwnPropertySymbols):
(JSC::objectConstructorKeys):
(JSC::ownEnumerablePropertyKeys):
(JSC::toPropertyDescriptor):
(JSC::defineProperties):
(JSC::objectConstructorDefineProperties):
(JSC::objectConstructorCreate):
(JSC::setIntegrityLevel):
(JSC::objectConstructorSeal):
(JSC::objectConstructorPreventExtensions):
(JSC::objectConstructorIsSealed):
(JSC::objectConstructorIsFrozen):
(JSC::ownPropertyKeys):
* runtime/ObjectPrototype.cpp:
(JSC::objectProtoFuncValueOf):
(JSC::objectProtoFuncHasOwnProperty):
(JSC::objectProtoFuncIsPrototypeOf):
(JSC::objectProtoFuncDefineGetter):
(JSC::objectProtoFuncDefineSetter):
(JSC::objectProtoFuncLookupGetter):
(JSC::objectProtoFuncLookupSetter):
(JSC::objectProtoFuncToLocaleString):
(JSC::objectProtoFuncToString):

Source/WebCore:

No new tests because this is covered by the existing test
http/tests/security/cross-frame-access-object-prototype.html with the help of a
new ASSERT in ObjectPrototype.cpp.

Fixed jsDOMWindowGetOwnPropertySlotRestrictedAccess() to return false when it
throws an exception.

* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::jsDOMWindowGetOwnPropertySlotRestrictedAccess):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (209019 => 209020)


--- trunk/Source/_javascript_Core/ChangeLog	2016-11-28 22:24:08 UTC (rev 209019)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-11-28 22:29:39 UTC (rev 209020)
@@ -1,3 +1,44 @@
+2016-11-28  Mark Lam  <[email protected]>
+
+        Fix exception scope verification failures in ObjectConstructor.cpp and ObjectPrototype.cpp.
+        https://bugs.webkit.org/show_bug.cgi?id=165051
+
+        Reviewed by Saam Barati.
+
+        Also,
+        1. Replaced returning JSValue() with returning { }.
+        2. Replaced uses of exec->propertyNames() with vm.propertyNames.
+
+        * runtime/ObjectConstructor.cpp:
+        (JSC::constructObject):
+        (JSC::objectConstructorGetPrototypeOf):
+        (JSC::objectConstructorGetOwnPropertyDescriptor):
+        (JSC::objectConstructorGetOwnPropertyDescriptors):
+        (JSC::objectConstructorGetOwnPropertyNames):
+        (JSC::objectConstructorGetOwnPropertySymbols):
+        (JSC::objectConstructorKeys):
+        (JSC::ownEnumerablePropertyKeys):
+        (JSC::toPropertyDescriptor):
+        (JSC::defineProperties):
+        (JSC::objectConstructorDefineProperties):
+        (JSC::objectConstructorCreate):
+        (JSC::setIntegrityLevel):
+        (JSC::objectConstructorSeal):
+        (JSC::objectConstructorPreventExtensions):
+        (JSC::objectConstructorIsSealed):
+        (JSC::objectConstructorIsFrozen):
+        (JSC::ownPropertyKeys):
+        * runtime/ObjectPrototype.cpp:
+        (JSC::objectProtoFuncValueOf):
+        (JSC::objectProtoFuncHasOwnProperty):
+        (JSC::objectProtoFuncIsPrototypeOf):
+        (JSC::objectProtoFuncDefineGetter):
+        (JSC::objectProtoFuncDefineSetter):
+        (JSC::objectProtoFuncLookupGetter):
+        (JSC::objectProtoFuncLookupSetter):
+        (JSC::objectProtoFuncToLocaleString):
+        (JSC::objectProtoFuncToString):
+
 2016-11-26  Mark Lam  <[email protected]>
 
         Fix exception scope verification failures in miscellaneous files.

Modified: trunk/Source/_javascript_Core/runtime/ObjectConstructor.cpp (209019 => 209020)


--- trunk/Source/_javascript_Core/runtime/ObjectConstructor.cpp	2016-11-28 22:24:08 UTC (rev 209019)
+++ trunk/Source/_javascript_Core/runtime/ObjectConstructor.cpp	2016-11-28 22:29:39 UTC (rev 209020)
@@ -133,6 +133,7 @@
         return constructEmptyObject(exec, globalObject->objectStructureForObjectConstructor());
 
     // 3. Return ToObject(value).
+    scope.release();
     return arg.toObject(exec, globalObject);
 }
 
@@ -164,7 +165,8 @@
     auto scope = DECLARE_THROW_SCOPE(vm);
     JSObject* object = exec->argument(0).toObject(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
-    return JSValue::encode(object->getPrototype(exec->vm(), exec));
+    scope.release();
+    return JSValue::encode(object->getPrototype(vm, exec));
 }
 
 EncodedJSValue JSC_HOST_CALL objectConstructorSetPrototypeOf(ExecState* exec)
@@ -194,11 +196,14 @@
     VM& vm = exec->vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
     PropertyDescriptor descriptor;
-    if (!object->getOwnPropertyDescriptor(exec, propertyName, descriptor))
+    if (!object->getOwnPropertyDescriptor(exec, propertyName, descriptor)) {
+        scope.release();
         return jsUndefined();
-    RETURN_IF_EXCEPTION(scope, JSValue());
+    }
+    RETURN_IF_EXCEPTION(scope, { });
 
     JSObject* result = constructObjectFromPropertyDescriptor(exec, descriptor);
+    ASSERT(!!scope.exception() == !result);
     if (!result)
         return jsUndefined();
     return result;
@@ -210,20 +215,21 @@
     auto scope = DECLARE_THROW_SCOPE(vm);
     PropertyNameArray properties(exec, PropertyNameMode::StringsAndSymbols);
     object->methodTable(vm)->getOwnPropertyNames(object, exec, properties, EnumerationMode(DontEnumPropertiesMode::Include));
-    RETURN_IF_EXCEPTION(scope, JSValue());
+    RETURN_IF_EXCEPTION(scope, { });
 
     JSObject* descriptors = constructEmptyObject(exec);
-    RETURN_IF_EXCEPTION(scope, JSValue());
+    RETURN_IF_EXCEPTION(scope, { });
 
     for (auto& propertyName : properties) {
         PropertyDescriptor descriptor;
         bool didGetDescriptor = object->getOwnPropertyDescriptor(exec, propertyName, descriptor);
-        RETURN_IF_EXCEPTION(scope, JSValue());
+        RETURN_IF_EXCEPTION(scope, { });
 
         if (!didGetDescriptor)
             continue;
 
         JSObject* fromDescriptor = constructObjectFromPropertyDescriptor(exec, descriptor);
+        ASSERT(!!scope.exception() == !fromDescriptor);
         if (!fromDescriptor)
             return jsUndefined();
 
@@ -243,6 +249,7 @@
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
     auto propertyName = exec->argument(1).toPropertyKey(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
+    scope.release();
     return JSValue::encode(objectConstructorGetOwnPropertyDescriptor(exec, object, propertyName));
 }
 
@@ -252,6 +259,7 @@
     auto scope = DECLARE_THROW_SCOPE(vm);
     JSObject* object = exec->argument(0).toObject(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
+    scope.release();
     return JSValue::encode(objectConstructorGetOwnPropertyDescriptors(exec, object));
 }
 
@@ -262,6 +270,7 @@
     auto scope = DECLARE_THROW_SCOPE(vm);
     JSObject* object = exec->argument(0).toObject(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
+    scope.release();
     return JSValue::encode(ownPropertyKeys(exec, object, PropertyNameMode::Strings, DontEnumPropertiesMode::Include));
 }
 
@@ -272,6 +281,7 @@
     auto scope = DECLARE_THROW_SCOPE(vm);
     JSObject* object = exec->argument(0).toObject(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
+    scope.release();
     return JSValue::encode(ownPropertyKeys(exec, object, PropertyNameMode::Symbols, DontEnumPropertiesMode::Include));
 }
 
@@ -282,6 +292,7 @@
     auto scope = DECLARE_THROW_SCOPE(vm);
     JSObject* object = exec->argument(0).toObject(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
+    scope.release();
     return JSValue::encode(ownPropertyKeys(exec, object, PropertyNameMode::Strings, DontEnumPropertiesMode::Exclude));
 }
 
@@ -291,6 +302,7 @@
     auto scope = DECLARE_THROW_SCOPE(vm);
     JSObject* object = exec->argument(0).toObject(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
+    scope.release();
     return JSValue::encode(ownPropertyKeys(exec, object, PropertyNameMode::StringsAndSymbols, DontEnumPropertiesMode::Exclude));
 }
 
@@ -307,15 +319,19 @@
     }
     JSObject* description = asObject(in);
 
-    if (description->hasProperty(exec, exec->propertyNames().enumerable)) {
-        JSValue value = description->get(exec, exec->propertyNames().enumerable);
+    bool hasProperty = description->hasProperty(exec, vm.propertyNames->enumerable);
+    ASSERT(!scope.exception() || !hasProperty);
+    if (hasProperty) {
+        JSValue value = description->get(exec, vm.propertyNames->enumerable);
         RETURN_IF_EXCEPTION(scope, false);
         desc.setEnumerable(value.toBoolean(exec));
     } else
         RETURN_IF_EXCEPTION(scope, false);
 
-    if (description->hasProperty(exec, exec->propertyNames().configurable)) {
-        JSValue value = description->get(exec, exec->propertyNames().configurable);
+    hasProperty = description->hasProperty(exec, vm.propertyNames->configurable);
+    ASSERT(!scope.exception() || !hasProperty);
+    if (hasProperty) {
+        JSValue value = description->get(exec, vm.propertyNames->configurable);
         RETURN_IF_EXCEPTION(scope, false);
         desc.setConfigurable(value.toBoolean(exec));
     } else
@@ -322,22 +338,28 @@
         RETURN_IF_EXCEPTION(scope, false);
 
     JSValue value;
-    if (description->hasProperty(exec, exec->propertyNames().value)) {
-        JSValue value = description->get(exec, exec->propertyNames().value);
+    hasProperty = description->hasProperty(exec, vm.propertyNames->value);
+    ASSERT(!scope.exception() || !hasProperty);
+    if (hasProperty) {
+        JSValue value = description->get(exec, vm.propertyNames->value);
         RETURN_IF_EXCEPTION(scope, false);
         desc.setValue(value);
     } else
         RETURN_IF_EXCEPTION(scope, false);
 
-    if (description->hasProperty(exec, exec->propertyNames().writable)) {
-        JSValue value = description->get(exec, exec->propertyNames().writable);
+    hasProperty = description->hasProperty(exec, vm.propertyNames->writable);
+    ASSERT(!scope.exception() || !hasProperty);
+    if (hasProperty) {
+        JSValue value = description->get(exec, vm.propertyNames->writable);
         RETURN_IF_EXCEPTION(scope, false);
         desc.setWritable(value.toBoolean(exec));
     } else
         RETURN_IF_EXCEPTION(scope, false);
 
-    if (description->hasProperty(exec, exec->propertyNames().get)) {
-        JSValue get = description->get(exec, exec->propertyNames().get);
+    hasProperty = description->hasProperty(exec, vm.propertyNames->get);
+    ASSERT(!scope.exception() || !hasProperty);
+    if (hasProperty) {
+        JSValue get = description->get(exec, vm.propertyNames->get);
         RETURN_IF_EXCEPTION(scope, false);
         if (!get.isUndefined()) {
             CallData callData;
@@ -350,8 +372,10 @@
     } else
         RETURN_IF_EXCEPTION(scope, false);
 
-    if (description->hasProperty(exec, exec->propertyNames().set)) {
-        JSValue set = description->get(exec, exec->propertyNames().set);
+    hasProperty = description->hasProperty(exec, vm.propertyNames->set);
+    ASSERT(!scope.exception() || !hasProperty);
+    if (hasProperty) {
+        JSValue set = description->get(exec, vm.propertyNames->set);
         RETURN_IF_EXCEPTION(scope, false);
         if (!set.isUndefined()) {
             CallData callData;
@@ -408,15 +432,17 @@
 
     PropertyNameArray propertyNames(exec, PropertyNameMode::StringsAndSymbols);
     asObject(properties)->methodTable(vm)->getOwnPropertyNames(asObject(properties), exec, propertyNames, EnumerationMode(DontEnumPropertiesMode::Exclude));
-    RETURN_IF_EXCEPTION(scope, JSValue());
+    RETURN_IF_EXCEPTION(scope, { });
     size_t numProperties = propertyNames.size();
     Vector<PropertyDescriptor> descriptors;
     MarkedArgumentBuffer markBuffer;
     for (size_t i = 0; i < numProperties; i++) {
         JSValue prop = properties->get(exec, propertyNames[i]);
-        RETURN_IF_EXCEPTION(scope, JSValue());
+        RETURN_IF_EXCEPTION(scope, { });
         PropertyDescriptor descriptor;
-        if (!toPropertyDescriptor(exec, prop, descriptor))
+        bool success = toPropertyDescriptor(exec, prop, descriptor);
+        ASSERT(!scope.exception() || !success);
+        if (UNLIKELY(!success))
             return jsNull();
         descriptors.append(descriptor);
         // Ensure we mark all the values that we're accumulating
@@ -431,10 +457,10 @@
     }
     for (size_t i = 0; i < numProperties; i++) {
         Identifier propertyName = propertyNames[i];
-        if (exec->propertyNames().isPrivateName(propertyName))
+        if (vm.propertyNames->isPrivateName(propertyName))
             continue;
         object->methodTable(vm)->defineOwnProperty(object, exec, propertyName, descriptors[i], true);
-        RETURN_IF_EXCEPTION(scope, JSValue());
+        RETURN_IF_EXCEPTION(scope, { });
     }
     return object;
 }
@@ -448,8 +474,10 @@
         return throwVMTypeError(exec, scope, ASCIILiteral("Properties can only be defined on Objects."));
     JSObject* targetObj = asObject(exec->argument(0));
     JSObject* props = exec->argument(1).toObject(exec);
-    if (!props)
-        return JSValue::encode(JSValue());
+    ASSERT(!!scope.exception() == !props);
+    if (UNLIKELY(!props))
+        return encodedJSValue();
+    scope.release();
     return JSValue::encode(defineProperties(exec, targetObj, props));
 }
 
@@ -468,6 +496,7 @@
         return JSValue::encode(newObject);
     if (!exec->argument(1).isObject())
         return throwVMTypeError(exec, scope, ASCIILiteral("Property descriptor list must be an Object."));
+    scope.release();
     return JSValue::encode(defineProperties(exec, newObject, asObject(exec->argument(1))));
 }
 
@@ -501,7 +530,9 @@
         if (level == IntegrityLevel::Sealed)
             desc.setConfigurable(false);
         else {
-            if (!object->getOwnPropertyDescriptor(exec, propertyName, desc))
+            bool hasPropertyDescriptor = object->getOwnPropertyDescriptor(exec, propertyName, desc);
+            RETURN_IF_EXCEPTION(scope, false);
+            if (!hasPropertyDescriptor)
                 continue;
 
             if (desc.isDataDescriptor())
@@ -534,7 +565,7 @@
 
     bool success = setIntegrityLevel<IntegrityLevel::Sealed>(exec, vm, object);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
-    if (!success) {
+    if (UNLIKELY(!success)) {
         throwTypeError(exec, scope, ASCIILiteral("Unable to prevent extension in Object.seal"));
         return encodedJSValue();
     }
@@ -574,11 +605,12 @@
 
 EncodedJSValue JSC_HOST_CALL objectConstructorPreventExtensions(ExecState* exec)
 {
+    VM& vm = exec->vm();
     JSValue argument = exec->argument(0);
     if (!argument.isObject())
         return JSValue::encode(argument);
     JSObject* object = asObject(argument);
-    object->methodTable(exec->vm())->preventExtensions(object, exec);
+    object->methodTable(vm)->preventExtensions(object, exec);
     return JSValue::encode(object);
 }
 
@@ -603,7 +635,7 @@
     PropertyNameArray::const_iterator end = properties.end();
     for (PropertyNameArray::const_iterator iter = properties.begin(); iter != end; ++iter) {
         Identifier propertyName = *iter;
-        if (exec->propertyNames().isPrivateName(propertyName))
+        if (vm.propertyNames->isPrivateName(propertyName))
             continue;
         // a. Let desc be the result of calling the [[GetOwnProperty]] internal method of O with P.
         PropertyDescriptor desc;
@@ -642,7 +674,7 @@
     PropertyNameArray::const_iterator end = properties.end();
     for (PropertyNameArray::const_iterator iter = properties.begin(); iter != end; ++iter) {
         Identifier propertyName = *iter;
-        if (exec->propertyNames().isPrivateName(propertyName))
+        if (vm.propertyNames->isPrivateName(propertyName))
             continue;
         // a. Let desc be the result of calling the [[GetOwnProperty]] internal method of O with P.
         PropertyDescriptor desc;
@@ -698,6 +730,7 @@
             const auto& identifier = properties[i];
             ASSERT(!identifier.isSymbol());
             keys->push(exec, jsOwnedString(exec, identifier.string()));
+            RETURN_IF_EXCEPTION(scope, nullptr);
         }
         break;
     }
@@ -707,8 +740,10 @@
         for (size_t i = 0; i < numProperties; i++) {
             const auto& identifier = properties[i];
             ASSERT(identifier.isSymbol());
-            if (!exec->propertyNames().isPrivateName(identifier))
+            if (!vm.propertyNames->isPrivateName(identifier)) {
                 keys->push(exec, Symbol::create(vm, static_cast<SymbolImpl&>(*identifier.impl())));
+                RETURN_IF_EXCEPTION(scope, nullptr);
+            }
         }
         break;
     }
@@ -719,15 +754,19 @@
         for (size_t i = 0; i < numProperties; i++) {
             const auto& identifier = properties[i];
             if (identifier.isSymbol()) {
-                if (!exec->propertyNames().isPrivateName(identifier))
+                if (!vm.propertyNames->isPrivateName(identifier))
                     propertySymbols.append(identifier);
-            } else
+            } else {
                 keys->push(exec, jsOwnedString(exec, identifier.string()));
+                RETURN_IF_EXCEPTION(scope, nullptr);
+            }
         }
 
         // To ensure the order defined in the spec (9.1.12), we append symbols at the last elements of keys.
-        for (const auto& identifier : propertySymbols)
+        for (const auto& identifier : propertySymbols) {
             keys->push(exec, Symbol::create(vm, static_cast<SymbolImpl&>(*identifier.impl())));
+            RETURN_IF_EXCEPTION(scope, nullptr);
+        }
 
         break;
     }

Modified: trunk/Source/_javascript_Core/runtime/ObjectPrototype.cpp (209019 => 209020)


--- trunk/Source/_javascript_Core/runtime/ObjectPrototype.cpp	2016-11-28 22:24:08 UTC (rev 209019)
+++ trunk/Source/_javascript_Core/runtime/ObjectPrototype.cpp	2016-11-28 22:29:39 UTC (rev 209020)
@@ -83,8 +83,8 @@
 {
     JSValue thisValue = exec->thisValue().toThis(exec, StrictMode);
     JSObject* valueObj = thisValue.toObject(exec);
-    if (!valueObj)
-        return JSValue::encode(JSValue());
+    if (UNLIKELY(!valueObj))
+        return encodedJSValue();
     return JSValue::encode(valueObj);
 }
 
@@ -97,8 +97,9 @@
     auto propertyName = exec->argument(0).toPropertyKey(exec);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
     JSObject* thisObject = thisValue.toObject(exec);
+    ASSERT(!!scope.exception() == !thisObject);
     if (UNLIKELY(!thisObject))
-        return JSValue::encode(JSValue());
+        return encodedJSValue();
 
     Structure* structure = thisObject->structure(vm);
     HasOwnPropertyCache* hasOwnPropertyCache = vm.ensureHasOwnPropertyCache();
@@ -123,8 +124,9 @@
 
     JSValue thisValue = exec->thisValue().toThis(exec, StrictMode);
     JSObject* thisObj = thisValue.toObject(exec);
-    if (!thisObj)
-        return JSValue::encode(JSValue());
+    ASSERT(!!scope.exception() == !thisObj);
+    if (UNLIKELY(!thisObj))
+        return encodedJSValue();
 
     if (!exec->argument(0).isObject())
         return JSValue::encode(jsBoolean(false));
@@ -164,6 +166,7 @@
     descriptor.setConfigurable(true);
 
     bool shouldThrow = true;
+    scope.release();
     thisObject->methodTable(vm)->defineOwnProperty(thisObject, exec, propertyName, descriptor, shouldThrow);
 
     return JSValue::encode(jsUndefined());
@@ -191,6 +194,7 @@
     descriptor.setConfigurable(true);
 
     bool shouldThrow = true;
+    scope.release();
     thisObject->methodTable(vm)->defineOwnProperty(thisObject, exec, propertyName, descriptor, shouldThrow);
 
     return JSValue::encode(jsUndefined());
@@ -208,7 +212,9 @@
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     PropertySlot slot(thisObject, PropertySlot::InternalMethodType::GetOwnProperty);
-    if (thisObject->getPropertySlot(exec, propertyName, slot)) {
+    bool hasProperty = thisObject->getPropertySlot(exec, propertyName, slot);
+    ASSERT(!scope.exception() || !hasProperty);
+    if (hasProperty) {
         if (slot.isAccessor()) {
             GetterSetter* getterSetter = slot.getterSetter();
             return getterSetter->isGetterNull() ? JSValue::encode(jsUndefined()) : JSValue::encode(getterSetter->getter());
@@ -236,7 +242,9 @@
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     PropertySlot slot(thisObject, PropertySlot::InternalMethodType::GetOwnProperty);
-    if (thisObject->getPropertySlot(exec, propertyName, slot)) {
+    bool hasProperty = thisObject->getPropertySlot(exec, propertyName, slot);
+    ASSERT(!scope.exception() || !hasProperty);
+    if (hasProperty) {
         if (slot.isAccessor()) {
             GetterSetter* getterSetter = slot.getterSetter();
             return getterSetter->isSetterNull() ? JSValue::encode(jsUndefined()) : JSValue::encode(getterSetter->setter());
@@ -278,7 +286,8 @@
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     // 2. Let toString be the result of calling the [[Get]] internal method of O passing "toString" as the argument.
-    JSValue toString = object->get(exec, exec->propertyNames().toString);
+    JSValue toString = object->get(exec, vm.propertyNames->toString);
+    RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     // 3. If IsCallable(toString) is false, throw a TypeError exception.
     CallData callData;
@@ -287,6 +296,7 @@
         return JSValue::encode(jsUndefined());
 
     // 4. Return the result of calling the [[Call]] internal method of toString passing O as the this value and no arguments.
+    scope.release();
     return JSValue::encode(call(exec, toString, callType, callData, object, exec->emptyList()));
 }
 
@@ -299,6 +309,7 @@
     if (thisValue.isUndefinedOrNull())
         return JSValue::encode(thisValue.isUndefined() ? vm.smallStrings.undefinedObjectString() : vm.smallStrings.nullObjectString());
     JSObject* thisObject = thisValue.toObject(exec);
+    ASSERT(!!scope.exception() == !thisObject);
     if (!thisObject)
         return JSValue::encode(jsUndefined());
 
@@ -306,11 +317,12 @@
     if (result)
         return JSValue::encode(result);
 
-    PropertyName toStringTagSymbol = exec->propertyNames().toStringTagSymbol;
+    PropertyName toStringTagSymbol = vm.propertyNames->toStringTagSymbol;
+    scope.release();
     return JSValue::encode(thisObject->getPropertySlot(exec, toStringTagSymbol, [&] (bool found, PropertySlot& toStringTagSlot) -> JSValue {
         if (found) {
             JSValue stringTag = toStringTagSlot.getValue(exec, toStringTagSymbol);
-            RETURN_IF_EXCEPTION(scope, JSValue());
+            RETURN_IF_EXCEPTION(scope, { });
             if (stringTag.isString()) {
                 JSRopeString::RopeBuilder ropeBuilder(vm);
                 ropeBuilder.append(vm.smallStrings.objectStringStart());
@@ -323,8 +335,8 @@
             }
         }
 
-        String tag = thisObject->methodTable(exec->vm())->toStringName(thisObject, exec);
-        RETURN_IF_EXCEPTION(scope, JSValue());
+        String tag = thisObject->methodTable(vm)->toStringName(thisObject, exec);
+        RETURN_IF_EXCEPTION(scope, { });
         String newString = WTF::tryMakeString("[object ", WTFMove(tag), "]");
         if (!newString)
             return throwOutOfMemoryError(exec, scope);

Modified: trunk/Source/WebCore/ChangeLog (209019 => 209020)


--- trunk/Source/WebCore/ChangeLog	2016-11-28 22:24:08 UTC (rev 209019)
+++ trunk/Source/WebCore/ChangeLog	2016-11-28 22:29:39 UTC (rev 209020)
@@ -1,3 +1,20 @@
+2016-11-28  Mark Lam  <[email protected]>
+
+        Fix exception scope verification failures in ObjectConstructor.cpp and ObjectPrototype.cpp.
+        https://bugs.webkit.org/show_bug.cgi?id=165051
+
+        Reviewed by Saam Barati.
+
+        No new tests because this is covered by the existing test
+        http/tests/security/cross-frame-access-object-prototype.html with the help of a
+        new ASSERT in ObjectPrototype.cpp.
+
+        Fixed jsDOMWindowGetOwnPropertySlotRestrictedAccess() to return false when it
+        throws an exception.
+
+        * bindings/js/JSDOMWindowCustom.cpp:
+        (WebCore::jsDOMWindowGetOwnPropertySlotRestrictedAccess):
+
 2016-11-28  Tim Horton  <[email protected]>
 
         Obvious change in saturation/color when swiping to a previously visited page

Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp (209019 => 209020)


--- trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp	2016-11-28 22:24:08 UTC (rev 209019)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp	2016-11-28 22:29:39 UTC (rev 209020)
@@ -134,7 +134,7 @@
         // FIXME comment on prototype search below.)
         throwSecurityError(*exec, scope, errorMessage);
         slot.setUndefined();
-        return true;
+        return false;
     }
 
     // Check for child frames by name before built-in properties to match Mozilla. This does
@@ -148,7 +148,7 @@
 
     throwSecurityError(*exec, scope, errorMessage);
     slot.setUndefined();
-    return true;
+    return false;
 }
 
 // Property access sequence is:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to