Skip to content

Commit e0bb118

Browse files
committed
tls_wrap: inherit from the AsyncWrap first
`WrapperInfo` casts pointer in JS object's internal field to `AsyncWrap`. This approach fails miserably for `TLSWrap` because it was inhereted from the `StreamBase` first, creating different kind of `vtable` for the whole class. Reorder parent classes to put `AsyncWrap` first. Fix: #4250 PR-URL: #4268 Reviewed-By: James M Snell <[email protected]>
1 parent d3c498b commit e0bb118

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/tls_wrap.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ TLSWrap::TLSWrap(Environment* env,
3636
Kind kind,
3737
StreamBase* stream,
3838
SecureContext* sc)
39-
: SSLWrap<TLSWrap>(env, sc, kind),
40-
StreamBase(env),
41-
AsyncWrap(env,
39+
: AsyncWrap(env,
4240
env->tls_wrap_constructor_function()->NewInstance(),
4341
AsyncWrap::PROVIDER_TLSWRAP),
42+
SSLWrap<TLSWrap>(env, sc, kind),
43+
StreamBase(env),
4444
sc_(sc),
4545
stream_(stream),
4646
enc_in_(nullptr),

src/tls_wrap.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ namespace crypto {
2121
class SecureContext;
2222
}
2323

24-
class TLSWrap : public crypto::SSLWrap<TLSWrap>,
25-
public StreamBase,
26-
public AsyncWrap {
24+
class TLSWrap : public AsyncWrap,
25+
public crypto::SSLWrap<TLSWrap>,
26+
public StreamBase {
2727
public:
2828
~TLSWrap() override;
2929

0 commit comments

Comments
 (0)