Fix exception scope verification failures in runtime/Intl* files.
[WebKit-https.git] / Source / JavaScriptCore / runtime / IntlObjectInlines.h
index 129d985538f5b882c00cd9dcf03473b07bec64c8..eb0e859764d182863f0fc0ab53e953c444bcfd60 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2016 Yusuke Suzuki <yusuke.suzuki@sslab.ics.keio.ac.jp>
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -27,6 +28,7 @@
 
 #if ENABLE(INTL)
 
+#include "BuiltinNames.h"
 #include "IntlObject.h"
 #include "JSObject.h"
 
@@ -38,22 +40,24 @@ JSValue constructIntlInstanceWithWorkaroundForLegacyIntlConstructor(ExecState& s
     // FIXME: Workaround to provide compatibility with ECMA-402 1.0 call/apply patterns.
     // https://bugs.webkit.org/show_bug.cgi?id=153679
     VM& vm = state.vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+
     if (!jsDynamicCast<IntlInstance*>(thisValue)) {
         JSValue prototype = callee->getDirect(vm, vm.propertyNames->prototype);
-        if (JSObject::defaultHasInstance(&state, thisValue, prototype)) {
+        bool hasInstance = JSObject::defaultHasInstance(&state, thisValue, prototype);
+        RETURN_IF_EXCEPTION(scope, JSValue());
+        if (hasInstance) {
             JSObject* thisObject = thisValue.toObject(&state);
-            if (state.hadException())
-                return jsUndefined();
+            RETURN_IF_EXCEPTION(scope, JSValue());
 
             IntlInstance* instance = factory(vm);
-            if (state.hadException())
-                return jsUndefined();
+            RETURN_IF_EXCEPTION(scope, JSValue());
 
-            thisObject->putDirect(vm, vm.propertyNames->intlSubstituteValuePrivateName, instance);
+            thisObject->putDirect(vm, vm.propertyNames->builtinNames().intlSubstituteValuePrivateName(), instance);
             return thisObject;
         }
     }
-
+    scope.release();
     return factory(vm);
 }