diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-02-15 13:17:31 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-02-17 20:07:30 +0300 |
commit | 586318aa9f70cdd0f5e0bc93b031ff68f572ed64 (patch) | |
tree | ea6f193e39702a738aa1a4f50ad62ac5d7c4494c /src/js_stream.cc | |
parent | 009efd0ec398455b7563020a684ef0c9f7f213a2 (diff) |
src: check HasCaught() in JSStream calls
`MakeCallback` can return an empty `MaybeLocal<>` even if no
exception has been generated, in particular, if
we were already terminating the current thread *before* the `TryCatch`
scope started, which meant it would not have an exception to report.
PR-URL: https://github.com/nodejs/node/pull/26124
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/js_stream.cc')
-rw-r--r-- | src/js_stream.cc | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/js_stream.cc b/src/js_stream.cc index 32dea04db5a..ae1aa7cd30e 100644 --- a/src/js_stream.cc +++ b/src/js_stream.cc @@ -46,7 +46,7 @@ bool JSStream::IsClosing() { TryCatchScope try_catch(env()); Local<Value> value; if (!MakeCallback(env()->isclosing_string(), 0, nullptr).ToLocal(&value)) { - if (!try_catch.HasTerminated()) + if (try_catch.HasCaught() && !try_catch.HasTerminated()) FatalException(env()->isolate(), try_catch); return true; } @@ -62,7 +62,7 @@ int JSStream::ReadStart() { int value_int = UV_EPROTO; if (!MakeCallback(env()->onreadstart_string(), 0, nullptr).ToLocal(&value) || !value->Int32Value(env()->context()).To(&value_int)) { - if (!try_catch.HasTerminated()) + if (try_catch.HasCaught() && !try_catch.HasTerminated()) FatalException(env()->isolate(), try_catch); } return value_int; @@ -77,7 +77,7 @@ int JSStream::ReadStop() { int value_int = UV_EPROTO; if (!MakeCallback(env()->onreadstop_string(), 0, nullptr).ToLocal(&value) || !value->Int32Value(env()->context()).To(&value_int)) { - if (!try_catch.HasTerminated()) + if (try_catch.HasCaught() && !try_catch.HasTerminated()) FatalException(env()->isolate(), try_catch); } return value_int; @@ -99,7 +99,7 @@ int JSStream::DoShutdown(ShutdownWrap* req_wrap) { arraysize(argv), argv).ToLocal(&value) || !value->Int32Value(env()->context()).To(&value_int)) { - if (!try_catch.HasTerminated()) + if (try_catch.HasCaught() && !try_catch.HasTerminated()) FatalException(env()->isolate(), try_catch); } return value_int; @@ -134,7 +134,7 @@ int JSStream::DoWrite(WriteWrap* w, arraysize(argv), argv).ToLocal(&value) || !value->Int32Value(env()->context()).To(&value_int)) { - if (!try_catch.HasTerminated()) + if (try_catch.HasCaught() && !try_catch.HasTerminated()) FatalException(env()->isolate(), try_catch); } return value_int; |