Skip to content

Commit 2220613

Browse files
committed
Exception check
1 parent 5434fc4 commit 2220613

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Source/JavaScriptCore/runtime/JSPromise.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,13 +772,15 @@ void JSPromise::resolveWithoutPromise(JSGlobalObject* globalObject, JSValue reso
772772

773773
void JSPromise::rejectWithoutPromise(JSGlobalObject* globalObject, JSValue argument, JSValue onFulfilled, JSValue onRejected, JSValue context)
774774
{
775+
VM& vm = globalObject->vm();
776+
auto scope = DECLARE_THROW_SCOPE(vm);
777+
775778
UNUSED_PARAM(onFulfilled);
776779
#if USE(BUN_JSC_ADDITIONS)
777780
// AsyncLocalStorage support: wrap context with async context if present
778781
if (auto* asyncContextData = globalObject->m_asyncContextData.get()) {
779782
JSValue asyncContext = asyncContextData->getInternalField(0);
780783
if (!asyncContext.isUndefined()) {
781-
VM& vm = globalObject->vm();
782784
// Create array [context, asyncContext]
783785
ObjectInitializationScope initializationScope(vm);
784786
JSArray* contextArray = JSArray::tryCreateUninitializedRestricted(initializationScope,
@@ -791,18 +793,21 @@ void JSPromise::rejectWithoutPromise(JSGlobalObject* globalObject, JSValue argum
791793
}
792794
}
793795
#endif
796+
scope.release();
794797
globalObject->queueMicrotask(InternalMicrotask::PromiseReactionJobWithoutPromise, onRejected, argument, context, jsUndefined());
795798
}
796799

797800
void JSPromise::fulfillWithoutPromise(JSGlobalObject* globalObject, JSValue argument, JSValue onFulfilled, JSValue onRejected, JSValue context)
798801
{
802+
VM& vm = globalObject->vm();
803+
auto scope = DECLARE_THROW_SCOPE(vm);
804+
799805
UNUSED_PARAM(onRejected);
800806
#if USE(BUN_JSC_ADDITIONS)
801807
// AsyncLocalStorage support: wrap context with async context if present
802808
if (auto* asyncContextData = globalObject->m_asyncContextData.get()) {
803809
JSValue asyncContext = asyncContextData->getInternalField(0);
804810
if (!asyncContext.isUndefined()) {
805-
VM& vm = globalObject->vm();
806811
// Create array [context, asyncContext]
807812
ObjectInitializationScope initializationScope(vm);
808813
JSArray* contextArray = JSArray::tryCreateUninitializedRestricted(initializationScope,
@@ -815,6 +820,7 @@ void JSPromise::fulfillWithoutPromise(JSGlobalObject* globalObject, JSValue argu
815820
}
816821
}
817822
#endif
823+
scope.release();
818824
globalObject->queueMicrotask(InternalMicrotask::PromiseReactionJobWithoutPromise, onFulfilled, argument, context, jsUndefined());
819825
}
820826

0 commit comments

Comments
 (0)