Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarshan Sen <raisinten@gmail.com>2022-03-26 18:39:59 +0300
committerGitHub <noreply@github.com>2022-03-26 18:39:59 +0300
commitbc395d4c53afaaa53f9088b90ae84249adbf4d2e (patch)
treee581017fa3b67e3e4fd30dd9646fd177a9e2d44b /src/js_udp_wrap.cc
parent99c46a62dae50e10f63e22f6becba99e56ffe975 (diff)
src: properly report exceptions from AddressToJS()
Signed-off-by: Darshan Sen <raisinten@gmail.com> PR-URL: https://github.com/nodejs/node/pull/42054 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'src/js_udp_wrap.cc')
-rw-r--r--src/js_udp_wrap.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/js_udp_wrap.cc b/src/js_udp_wrap.cc
index c01289033e6..3f02771ee1a 100644
--- a/src/js_udp_wrap.cc
+++ b/src/js_udp_wrap.cc
@@ -5,6 +5,9 @@
#include <algorithm>
+// TODO(RaisinTen): Replace all uses with empty `v8::Maybe`s.
+#define JS_EXCEPTION_PENDING UV_EPROTO
+
namespace node {
using errors::TryCatchScope;
@@ -60,7 +63,7 @@ int JSUDPWrap::RecvStart() {
Context::Scope context_scope(env()->context());
TryCatchScope try_catch(env());
Local<Value> value;
- int32_t value_int = UV_EPROTO;
+ int32_t value_int = JS_EXCEPTION_PENDING;
if (!MakeCallback(env()->onreadstart_string(), 0, nullptr).ToLocal(&value) ||
!value->Int32Value(env()->context()).To(&value_int)) {
if (try_catch.HasCaught() && !try_catch.HasTerminated())
@@ -74,7 +77,7 @@ int JSUDPWrap::RecvStop() {
Context::Scope context_scope(env()->context());
TryCatchScope try_catch(env());
Local<Value> value;
- int32_t value_int = UV_EPROTO;
+ int32_t value_int = JS_EXCEPTION_PENDING;
if (!MakeCallback(env()->onreadstop_string(), 0, nullptr).ToLocal(&value) ||
!value->Int32Value(env()->context()).To(&value_int)) {
if (try_catch.HasCaught() && !try_catch.HasTerminated())
@@ -90,7 +93,7 @@ ssize_t JSUDPWrap::Send(uv_buf_t* bufs,
Context::Scope context_scope(env()->context());
TryCatchScope try_catch(env());
Local<Value> value;
- int64_t value_int = UV_EPROTO;
+ int64_t value_int = JS_EXCEPTION_PENDING;
size_t total_len = 0;
MaybeStackBuffer<Local<Value>, 16> buffers(nbufs);
@@ -100,10 +103,13 @@ ssize_t JSUDPWrap::Send(uv_buf_t* bufs,
total_len += bufs[i].len;
}
+ Local<Object> address;
+ if (!AddressToJS(env(), addr).ToLocal(&address)) return value_int;
+
Local<Value> args[] = {
listener()->CreateSendWrap(total_len)->object(),
Array::New(env()->isolate(), buffers.out(), nbufs),
- AddressToJS(env(), addr)
+ address,
};
if (!MakeCallback(env()->onwrite_string(), arraysize(args), args)