[*] Fix crash under Aurora API

Last aurora commit: 9480aab0
This commit is contained in:
Reece Wilson 2023-10-20 13:52:44 +01:00
parent 9480aab0d3
commit 8fce4f1e0c

View File

@ -5487,6 +5487,7 @@ MaybeLocal<Function> Function::Bind(v8::Local<v8::Object> that,
i::Handle<i::JSReceiver> self;
i::Handle<i::Object> that_obj;
v8::Isolate* isolate = this->GetIsolate();
i::MaybeHandle<i::JSBoundFunction> bound_function;
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
if (that.IsEmpty()) {
@ -5505,18 +5506,24 @@ MaybeLocal<Function> Function::Bind(v8::Local<v8::Object> that,
self = Utils::OpenHandle(this);
// derive a base vector of internal object handles by unwrapping an optional v8::Array
base::ScopedVector<i::Handle<i::Object>> argv(bound_args.IsEmpty() ? 0 : bound_args->Length());
if (!bound_args.IsEmpty()) {
for (int i = 0; i < bound_args->Length(); ++i) {
MaybeLocal<Value> arg = bound_args->Get(isolate->GetCurrentContext(), i);
CHECK(!arg.IsEmpty());
argv[i] = Utils::OpenHandle(*arg.ToLocalChecked());
if (!bound_args.IsEmpty() && bound_args->Length()) {
base::ScopedVector<i::Handle<i::Object>> argv(
bound_args.IsEmpty() ? 0 : bound_args->Length());
if (!bound_args.IsEmpty()) {
for (int i = 0; i < bound_args->Length(); ++i) {
MaybeLocal<Value> arg =
bound_args->Get(isolate->GetCurrentContext(), i);
CHECK(!arg.IsEmpty());
argv[i] = Utils::OpenHandle(*arg.ToLocalChecked());
}
}
bound_function =
i_isolate->factory()->NewJSBoundFunction(self, that_obj, argv);
} else {
bound_function =
i_isolate->factory()->NewJSBoundFunction(self, that_obj, {});
}
i::MaybeHandle<i::JSBoundFunction> bound_function =
i_isolate->factory()->NewJSBoundFunction(self, that_obj, argv);
if (bound_function.is_null()) {
return {};
}