Fix exception scope verification failures in more miscellaneous files.
authormark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Nov 2016 22:56:08 +0000 (22:56 +0000)
committermark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Nov 2016 22:56:08 +0000 (22:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=165102

Reviewed by Saam Barati.

Source/JavaScriptCore:

* wasm/js/WebAssemblyInstanceConstructor.cpp:
(JSC::constructJSWebAssemblyInstance):

Source/WebCore:

No new tests because these are fixes to failures detected by existing tests when
exception check verification is enabled.

* bindings/js/IDBBindingUtilities.cpp:
(WebCore::toJS):
* bindings/js/JSCommandLineAPIHostCustom.cpp:
(WebCore::getJSListenerFunctions):
* bindings/js/JSCryptoKeySerializationJWK.cpp:
(WebCore::buildJSONForRSAComponents):
(WebCore::addUsagesToJSON):
* bindings/js/JSDOMBinding.h:
(WebCore::toJS):
* bridge/runtime_array.cpp:
(JSC::RuntimeArray::put):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209025 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.cpp
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/IDBBindingUtilities.cpp
Source/WebCore/bindings/js/JSCommandLineAPIHostCustom.cpp
Source/WebCore/bindings/js/JSCryptoKeySerializationJWK.cpp
Source/WebCore/bindings/js/JSDOMBinding.h
Source/WebCore/bridge/runtime_array.cpp

index 76c3b38..1f460bd 100644 (file)
@@ -1,5 +1,15 @@
 2016-11-28  Mark Lam  <mark.lam@apple.com>
 
+        Fix exception scope verification failures in more miscellaneous files.
+        https://bugs.webkit.org/show_bug.cgi?id=165102
+
+        Reviewed by Saam Barati.
+
+        * wasm/js/WebAssemblyInstanceConstructor.cpp:
+        (JSC::constructJSWebAssemblyInstance):
+
+2016-11-28  Mark Lam  <mark.lam@apple.com>
+
         Fix exception scope verification failures in runtime/Weak* files.
         https://bugs.webkit.org/show_bug.cgi?id=165096
 
index c8aea2f..e51dee4 100644 (file)
@@ -80,7 +80,9 @@ static EncodedJSValue JSC_HOST_CALL constructJSWebAssemblyInstance(ExecState* st
     VariableEnvironment declaredVariables;
     VariableEnvironment lexicalVariables;
     auto* moduleRecord = JSModuleRecord::create(state, vm, globalObject->moduleRecordStructure(), moduleKey, sourceCode, declaredVariables, lexicalVariables);
+    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     auto* moduleNamespaceObject = JSModuleNamespaceObject::create(state, globalObject, globalObject->moduleNamespaceObjectStructure(), moduleRecord, instanceExports);
+    RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     auto* structure = InternalFunction::createSubclassStructure(state, state->newTarget(), globalObject->WebAssemblyInstanceStructure());
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
index ec06cfe..750e347 100644 (file)
@@ -1,3 +1,25 @@
+2016-11-28  Mark Lam  <mark.lam@apple.com>
+
+        Fix exception scope verification failures in more miscellaneous files.
+        https://bugs.webkit.org/show_bug.cgi?id=165102
+
+        Reviewed by Saam Barati.
+
+        No new tests because these are fixes to failures detected by existing tests when
+        exception check verification is enabled.
+
+        * bindings/js/IDBBindingUtilities.cpp:
+        (WebCore::toJS):
+        * bindings/js/JSCommandLineAPIHostCustom.cpp:
+        (WebCore::getJSListenerFunctions):
+        * bindings/js/JSCryptoKeySerializationJWK.cpp:
+        (WebCore::buildJSONForRSAComponents):
+        (WebCore::addUsagesToJSON):
+        * bindings/js/JSDOMBinding.h:
+        (WebCore::toJS):
+        * bridge/runtime_array.cpp:
+        (JSC::RuntimeArray::put):
+
 2016-11-28  Dave Hyatt  <hyatt@apple.com>
 
         [CSS Parser] Fix bugs in the @supports parser
index a74dd18..12f57ba 100644 (file)
@@ -101,8 +101,10 @@ JSValue toJS(ExecState& state, JSGlobalObject& globalObject, IDBKey* key)
         unsigned size = inArray.size();
         auto outArray = constructEmptyArray(&state, 0, &globalObject, size);
         RETURN_IF_EXCEPTION(scope, JSValue());
-        for (size_t i = 0; i < size; ++i)
+        for (size_t i = 0; i < size; ++i) {
             outArray->putDirectIndex(&state, i, toJS(state, globalObject, inArray.at(i).get()));
+            RETURN_IF_EXCEPTION(scope, JSValue());
+        }
         return outArray;
     }
     case KeyType::Binary: {
index f9f9e09..7aaf6c8 100644 (file)
@@ -91,6 +91,7 @@ static JSArray* getJSListenerFunctions(ExecState& state, Document* document, con
         listenerEntry->putDirect(vm, Identifier::fromString(&state, "listener"), function);
         listenerEntry->putDirect(vm, Identifier::fromString(&state, "useCapture"), jsBoolean(listenerInfo.eventListenerVector[i]->useCapture()));
         result->putDirectIndex(&state, outputIndex++, JSValue(listenerEntry));
+        RETURN_IF_EXCEPTION(scope, nullptr);
     }
     return result;
 }
index 54a8d1f..92317c2 100644 (file)
@@ -571,6 +571,7 @@ static void buildJSONForRSAComponents(JSC::ExecState* exec, const CryptoKeyDataR
         addToJSON(exec, jsPrimeInfo, "d", base64URLEncode(data.otherPrimeInfos()[i].factorCRTExponent));
         addToJSON(exec, jsPrimeInfo, "t", base64URLEncode(data.otherPrimeInfos()[i].factorCRTCoefficient));
         oth->putDirectIndex(exec, i, jsPrimeInfo);
+        RETURN_IF_EXCEPTION(scope, void());
     }
     result->putDirect(vm, Identifier::fromString(exec, "oth"), oth);
 }
@@ -694,22 +695,38 @@ static void addUsagesToJSON(ExecState* exec, JSObject* json, CryptoKeyUsageBitma
     RETURN_IF_EXCEPTION(scope, void());
 
     unsigned index = 0;
-    if (usages & CryptoKeyUsageSign)
+    if (usages & CryptoKeyUsageSign) {
         keyOps->putDirectIndex(exec, index++, jsNontrivialString(exec, ASCIILiteral("sign")));
-    if (usages & CryptoKeyUsageVerify)
+        RETURN_IF_EXCEPTION(scope, void());
+    }
+    if (usages & CryptoKeyUsageVerify) {
         keyOps->putDirectIndex(exec, index++, jsNontrivialString(exec, ASCIILiteral("verify")));
-    if (usages & CryptoKeyUsageEncrypt)
+        RETURN_IF_EXCEPTION(scope, void());
+    }
+    if (usages & CryptoKeyUsageEncrypt) {
         keyOps->putDirectIndex(exec, index++, jsNontrivialString(exec, ASCIILiteral("encrypt")));
-    if (usages & CryptoKeyUsageDecrypt)
+        RETURN_IF_EXCEPTION(scope, void());
+    }
+    if (usages & CryptoKeyUsageDecrypt) {
         keyOps->putDirectIndex(exec, index++, jsNontrivialString(exec, ASCIILiteral("decrypt")));
-    if (usages & CryptoKeyUsageWrapKey)
+        RETURN_IF_EXCEPTION(scope, void());
+    }
+    if (usages & CryptoKeyUsageWrapKey) {
         keyOps->putDirectIndex(exec, index++, jsNontrivialString(exec, ASCIILiteral("wrapKey")));
-    if (usages & CryptoKeyUsageUnwrapKey)
+        RETURN_IF_EXCEPTION(scope, void());
+    }
+    if (usages & CryptoKeyUsageUnwrapKey) {
         keyOps->putDirectIndex(exec, index++, jsNontrivialString(exec, ASCIILiteral("unwrapKey")));
-    if (usages & CryptoKeyUsageDeriveKey)
+        RETURN_IF_EXCEPTION(scope, void());
+    }
+    if (usages & CryptoKeyUsageDeriveKey) {
         keyOps->putDirectIndex(exec, index++, jsNontrivialString(exec, ASCIILiteral("deriveKey")));
-    if (usages & CryptoKeyUsageDeriveBits)
+        RETURN_IF_EXCEPTION(scope, void());
+    }
+    if (usages & CryptoKeyUsageDeriveBits) {
         keyOps->putDirectIndex(exec, index++, jsNontrivialString(exec, ASCIILiteral("deriveBits")));
+        RETURN_IF_EXCEPTION(scope, void());
+    }
 
     json->putDirect(vm, Identifier::fromString(exec, "key_ops"), keyOps);
 }
index d7e644e..46a6ab6 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
- *  Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2013 Apple Inc. All rights reserved.
+ *  Copyright (C) 2003-2006, 2008-2009, 2013, 2016 Apple Inc. All rights reserved.
  *  Copyright (C) 2007 Samuel Weinig <sam@webkit.org>
  *  Copyright (C) 2009 Google, Inc. All rights reserved.
  *  Copyright (C) 2012 Ericsson AB. All rights reserved.
@@ -658,8 +658,10 @@ template<typename T> inline JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalO
 
     JSC::JSArray* array = constructEmptyArray(exec, nullptr, vector.size());
     RETURN_IF_EXCEPTION(scope, JSC::JSValue());
-    for (size_t i = 0; i < vector.size(); ++i)
+    for (size_t i = 0; i < vector.size(); ++i) {
         array->putDirectIndex(exec, i, toJS(exec, globalObject, vector[i]));
+        RETURN_IF_EXCEPTION(scope, JSC::JSValue());
+    }
     return array;
 }
 
@@ -670,8 +672,10 @@ template<typename T> inline JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalO
 
     JSC::JSArray* array = constructEmptyArray(exec, nullptr, vector.size());
     RETURN_IF_EXCEPTION(scope, JSC::JSValue());
-    for (size_t i = 0; i < vector.size(); ++i)
+    for (size_t i = 0; i < vector.size(); ++i) {
         array->putDirectIndex(exec, i, toJS(exec, globalObject, vector[i].get()));
+        RETURN_IF_EXCEPTION(scope, JSC::JSValue());
+    }
     return array;
 }
 
index b878871..266bf1e 100644 (file)
@@ -127,7 +127,8 @@ bool RuntimeArray::put(JSCell* cell, ExecState* exec, PropertyName propertyName,
     
     if (std::optional<uint32_t> index = parseIndex(propertyName))
         return thisObject->getConcreteArray()->setValueAt(exec, index.value(), value);
-    
+
+    scope.release();
     return JSObject::put(thisObject, exec, propertyName, value, slot);
 }