From e0bb118a1d5f8b6b1eb2405f2dc19b8118f8ec0e Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Mon, 14 Dec 2015 00:58:37 -0500 Subject: [PATCH] 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: https://github.com/nodejs/node/issues/4250 PR-URL: https://github.com/nodejs/node/pull/4268 Reviewed-By: James M Snell --- src/tls_wrap.cc | 6 +++--- src/tls_wrap.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index bc830dba74dd82..94f70eba5de6cb 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -36,11 +36,11 @@ TLSWrap::TLSWrap(Environment* env, Kind kind, StreamBase* stream, SecureContext* sc) - : SSLWrap(env, sc, kind), - StreamBase(env), - AsyncWrap(env, + : AsyncWrap(env, env->tls_wrap_constructor_function()->NewInstance(), AsyncWrap::PROVIDER_TLSWRAP), + SSLWrap(env, sc, kind), + StreamBase(env), sc_(sc), stream_(stream), enc_in_(nullptr), diff --git a/src/tls_wrap.h b/src/tls_wrap.h index 47cbf27fe288e5..31d19523a62d08 100644 --- a/src/tls_wrap.h +++ b/src/tls_wrap.h @@ -21,9 +21,9 @@ namespace crypto { class SecureContext; } -class TLSWrap : public crypto::SSLWrap, - public StreamBase, - public AsyncWrap { +class TLSWrap : public AsyncWrap, + public crypto::SSLWrap, + public StreamBase { public: ~TLSWrap() override;