Fix exception scope verification failures in runtime/Intl* files.
[WebKit-https.git] / Source / JavaScriptCore / runtime / IntlDateTimeFormatPrototype.cpp
index d75055c289ab9b5b4904f8548ddc31ada9d627d3..81420776a236582e9f34efdffd6a3023464fc0d9 100644 (file)
@@ -105,6 +105,7 @@ static EncodedJSValue JSC_HOST_CALL IntlDateTimeFormatFuncFormatDateTime(ExecSta
     }
 
     // 5. Return FormatDateTime(dtf, x).
     }
 
     // 5. Return FormatDateTime(dtf, x).
+    scope.release();
     return JSValue::encode(format->format(*state, value));
 }
 
     return JSValue::encode(format->format(*state, value));
 }
 
@@ -119,8 +120,11 @@ EncodedJSValue JSC_HOST_CALL IntlDateTimeFormatPrototypeGetterFormat(ExecState*
 
     // FIXME: Workaround to provide compatibility with ECMA-402 1.0 call/apply patterns.
     // https://bugs.webkit.org/show_bug.cgi?id=153679
 
     // FIXME: Workaround to provide compatibility with ECMA-402 1.0 call/apply patterns.
     // https://bugs.webkit.org/show_bug.cgi?id=153679
-    if (!dtf)
-        dtf = jsDynamicCast<IntlDateTimeFormat*>(state->thisValue().get(state, vm.propertyNames->builtinNames().intlSubstituteValuePrivateName()));
+    if (!dtf) {
+        JSValue value = state->thisValue().get(state, vm.propertyNames->builtinNames().intlSubstituteValuePrivateName());
+        RETURN_IF_EXCEPTION(scope, encodedJSValue());
+        dtf = jsDynamicCast<IntlDateTimeFormat*>(value);
+    }
 
     // 2. ReturnIfAbrupt(dtf).
     if (!dtf)
 
     // 2. ReturnIfAbrupt(dtf).
     if (!dtf)
@@ -157,12 +161,16 @@ EncodedJSValue JSC_HOST_CALL IntlDateTimeFormatPrototypeFuncResolvedOptions(Exec
 
     // FIXME: Workaround to provide compatibility with ECMA-402 1.0 call/apply patterns.
     // https://bugs.webkit.org/show_bug.cgi?id=153679
 
     // FIXME: Workaround to provide compatibility with ECMA-402 1.0 call/apply patterns.
     // https://bugs.webkit.org/show_bug.cgi?id=153679
-    if (!dateTimeFormat)
-        dateTimeFormat = jsDynamicCast<IntlDateTimeFormat*>(state->thisValue().get(state, vm.propertyNames->builtinNames().intlSubstituteValuePrivateName()));
+    if (!dateTimeFormat) {
+        JSValue value = state->thisValue().get(state, vm.propertyNames->builtinNames().intlSubstituteValuePrivateName());
+        RETURN_IF_EXCEPTION(scope, encodedJSValue());
+        dateTimeFormat = jsDynamicCast<IntlDateTimeFormat*>(value);
+    }
 
     if (!dateTimeFormat)
         return JSValue::encode(throwTypeError(state, scope, ASCIILiteral("Intl.DateTimeFormat.prototype.resolvedOptions called on value that's not an object initialized as a DateTimeFormat")));
 
 
     if (!dateTimeFormat)
         return JSValue::encode(throwTypeError(state, scope, ASCIILiteral("Intl.DateTimeFormat.prototype.resolvedOptions called on value that's not an object initialized as a DateTimeFormat")));
 
+    scope.release();
     return JSValue::encode(dateTimeFormat->resolvedOptions(*state));
 }
 
     return JSValue::encode(dateTimeFormat->resolvedOptions(*state));
 }