| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c22793d commit d9c47e9
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,6 +20,7 @@ using v8::Int32; | |||
| 20 | 20 | using v8::Isolate; | |
| 21 | 21 | using v8::Local; | |
| 22 | 22 | using v8::Object; | |
| 23 | + using v8::TryCatch; | ||
| 23 | 24 | using v8::Value; | |
| 24 | 25 | ||
| 25 | 26 | ||
@@ -169,6 +170,8 @@ void JSStream::ReadBuffer(const FunctionCallbackInfo<Value>& args) { | |||
| 169 | 170 | const char* data = buffer.data(); | |
| 170 | 171 | int len = buffer.length(); | |
| 171 | 172 | ||
| 173 | + TryCatch try_catch(args.GetIsolate()); | ||
| 174 | + | ||
| 172 | 175 | // Repeatedly ask the stream's owner for memory, copy the data that we | |
| 173 | 176 | // just read from JS into those buffers and emit them as reads. | |
| 174 | 177 | while (len != 0) { | |
@@ -182,6 +185,10 @@ void JSStream::ReadBuffer(const FunctionCallbackInfo<Value>& args) { | |||
| 182 | 185 | len -= static_cast<int>(avail); | |
| 183 | 186 | wrap->EmitRead(avail, buf); | |
| 184 | 187 | } | |
| 188 | + | ||
| 189 | + if (try_catch.HasCaught()) { | ||
| 190 | + try_catch.ReThrow(); | ||
| 191 | + } | ||
| 185 | 192 | } | |
| 186 | 193 | ||
| 187 | 194 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -462,13 +462,16 @@ bool ContextifyContext::IsStillInitializing(const ContextifyContext* ctx) { | |||
| 462 | 462 | void ContextifyContext::PropertyGetterCallback( | |
| 463 | 463 | Local<Name> property, | |
| 464 | 464 | const PropertyCallbackInfo<Value>& args) { | |
| 465 | + Environment* env = Environment::GetCurrent(args); | ||
| 465 | 466 | ContextifyContext* ctx = ContextifyContext::Get(args); | |
| 466 | 467 | ||
| 467 | 468 | // Still initializing | |
| 468 | 469 | if (IsStillInitializing(ctx)) return; | |
| 469 | 470 | ||
| 470 | 471 | Local<Context> context = ctx->context(); | |
| 471 | 472 | Local<Object> sandbox = ctx->sandbox(); | |
| 473 | + | ||
| 474 | + TryCatchScope try_catch(env); | ||
| 472 | 475 | MaybeLocal<Value> maybe_rv = | |
| 473 | 476 | sandbox->GetRealNamedProperty(context, property); | |
| 474 | 477 | if (maybe_rv.IsEmpty()) { | |
@@ -478,6 +481,9 @@ void ContextifyContext::PropertyGetterCallback( | |||
| 478 | 481 | ||
| 479 | 482 | Local<Value> rv; | |
| 480 | 483 | if (maybe_rv.ToLocal(&rv)) { | |
| 484 | + if (try_catch.HasCaught() && !try_catch.HasTerminated()) { | ||
| 485 | + try_catch.ReThrow(); | ||
| 486 | + } | ||
| 481 | 487 | if (rv == sandbox) | |
| 482 | 488 | rv = ctx->global_proxy(); | |
| 483 | 489 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -916,6 +916,7 @@ Maybe<bool> MessagePort::PostMessage(Environment* env, | |||
| 916 | 916 | const TransferList& transfer_v) { | |
| 917 | 917 | Isolate* isolate = env->isolate(); | |
| 918 | 918 | Local<Object> obj = object(isolate); | |
| 919 | + TryCatchScope try_catch(env); | ||
| 919 | 920 | ||
| 920 | 921 | std::shared_ptr<Message> msg = std::make_shared<Message>(); | |
| 921 | 922 | ||
@@ -924,6 +925,9 @@ Maybe<bool> MessagePort::PostMessage(Environment* env, | |||
| 924 | 925 | ||
| 925 | 926 | Maybe<bool> serialization_maybe = | |
| 926 | 927 | msg->Serialize(env, context, message_v, transfer_v, obj); | |
| 928 | + if (try_catch.HasCaught() && !try_catch.HasTerminated()) { | ||
| 929 | + try_catch.ReThrow(); | ||
| 930 | + } | ||
| 927 | 931 | if (data_ == nullptr) { | |
| 928 | 932 | return serialization_maybe; | |
| 929 | 933 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,6 +8,7 @@ using v8::FunctionCallbackInfo; | |||
| 8 | 8 | using v8::Isolate; | |
| 9 | 9 | using v8::Local; | |
| 10 | 10 | using v8::Object; | |
| 11 | + using v8::TryCatch; | ||
| 11 | 12 | using v8::Value; | |
| 12 | 13 | ||
| 13 | 14 | namespace { | |
@@ -19,8 +20,12 @@ void MakeCallback(const FunctionCallbackInfo<Value>& args) { | |||
| 19 | 20 | Local<Object> recv = args[0].As<Object>(); | |
| 20 | 21 | Local<Function> method = args[1].As<Function>(); | |
| 21 | 22 | ||
| 23 | + TryCatch try_catch(isolate); | ||
| 22 | 24 | node::MakeCallback(isolate, recv, method, 0, nullptr, | |
| 23 | 25 | node::async_context{0, 0}); | |
| 26 | + if (try_catch.HasCaught()) { | ||
| 27 | + try_catch.ReThrow(); | ||
| 28 | + } | ||
| 24 | 29 | } | |
| 25 | 30 | ||
| 26 | 31 | void Initialize(Local<Object> exports) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments