Skip to content

Commit 03908d2

Browse files
committed
src: pass along errors from tls object creation
PR-URL: #25822 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
1 parent d999b55 commit 03908d2

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/tls_wrap.cc

+10-5
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,11 @@ using v8::String;
4949
using v8::Value;
5050

5151
TLSWrap::TLSWrap(Environment* env,
52+
Local<Object> obj,
5253
Kind kind,
5354
StreamBase* stream,
5455
SecureContext* sc)
55-
: AsyncWrap(env,
56-
env->tls_wrap_constructor_function()
57-
->NewInstance(env->context()).ToLocalChecked(),
58-
AsyncWrap::PROVIDER_TLSWRAP),
56+
: AsyncWrap(env, obj, AsyncWrap::PROVIDER_TLSWRAP),
5957
SSLWrap<TLSWrap>(env, sc, kind),
6058
StreamBase(env),
6159
sc_(sc) {
@@ -160,7 +158,14 @@ void TLSWrap::Wrap(const FunctionCallbackInfo<Value>& args) {
160158
StreamBase* stream = static_cast<StreamBase*>(stream_obj->Value());
161159
CHECK_NOT_NULL(stream);
162160

163-
TLSWrap* res = new TLSWrap(env, kind, stream, Unwrap<SecureContext>(sc));
161+
Local<Object> obj;
162+
if (!env->tls_wrap_constructor_function()
163+
->NewInstance(env->context())
164+
.ToLocal(&obj)) {
165+
return;
166+
}
167+
168+
TLSWrap* res = new TLSWrap(env, obj, kind, stream, Unwrap<SecureContext>(sc));
164169

165170
args.GetReturnValue().Set(res->object());
166171
}

src/tls_wrap.h

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ class TLSWrap : public AsyncWrap,
108108
static const int kSimultaneousBufferCount = 10;
109109

110110
TLSWrap(Environment* env,
111+
v8::Local<v8::Object> obj,
111112
Kind kind,
112113
StreamBase* stream,
113114
crypto::SecureContext* sc);

0 commit comments

Comments
 (0)