Skip to content

Commit e3fd752

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

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
@@ -48,13 +48,11 @@ using v8::String;
4848
using v8::Value;
4949

5050
TLSWrap::TLSWrap(Environment* env,
51+
Local<Object> obj,
5152
Kind kind,
5253
StreamBase* stream,
5354
SecureContext* sc)
54-
: AsyncWrap(env,
55-
env->tls_wrap_constructor_function()
56-
->NewInstance(env->context()).ToLocalChecked(),
57-
AsyncWrap::PROVIDER_TLSWRAP),
55+
: AsyncWrap(env, obj, AsyncWrap::PROVIDER_TLSWRAP),
5856
SSLWrap<TLSWrap>(env, sc, kind),
5957
StreamBase(env),
6058
sc_(sc) {
@@ -159,7 +157,14 @@ void TLSWrap::Wrap(const FunctionCallbackInfo<Value>& args) {
159157
StreamBase* stream = static_cast<StreamBase*>(stream_obj->Value());
160158
CHECK_NOT_NULL(stream);
161159

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

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

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)