summaryrefslogtreecommitdiff
path: root/src/tls_wrap.h
diff options
context:
space:
mode:
authorTrevor Norris <trev.norris@gmail.com>2016-10-31 16:48:14 -0600
committerAnna Henningsen <anna@addaleax.net>2017-03-27 02:20:59 +0200
commitee463d335e05a6656001697152ee7ec056eb209b (patch)
tree414ef74abc7ef68f0ab517e4b851f7bf1ed457df /src/tls_wrap.h
parent0db49fef4152e3642c2a0686c30bf59813e7ce1c (diff)
downloadandroid-node-v8-ee463d335e05a6656001697152ee7ec056eb209b.tar.gz
android-node-v8-ee463d335e05a6656001697152ee7ec056eb209b.tar.bz2
android-node-v8-ee463d335e05a6656001697152ee7ec056eb209b.zip
stream_base,tls_wrap: notify on destruct
The TLSWrap constructor is passed a StreamBase* which it stores as TLSWrap::stream_, and is used to receive/send data along the pipeline (e.g. tls -> tcp). Problem is the lifetime of the instance that stream_ points to is independent of the lifetime of the TLSWrap instance. So it's possible for stream_ to be delete'd while the TLSWrap instance is still alive, allowing potential access to a then invalid pointer. Fix by having the StreamBase destructor null out TLSWrap::stream_; allowing all TLSWrap methods that rely on stream_ to do a check to see if it's available. While the test provided is fixed by this commit, it was also previously fixed by 478fabf. Regardless, leave the test in for better testing. PR-URL: https://github.com/nodejs/node/pull/11947 Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'src/tls_wrap.h')
-rw-r--r--src/tls_wrap.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/tls_wrap.h b/src/tls_wrap.h
index d6c4b62493..f1d53f3e2f 100644
--- a/src/tls_wrap.h
+++ b/src/tls_wrap.h
@@ -75,6 +75,8 @@ class TLSWrap : public AsyncWrap,
size_t self_size() const override { return sizeof(*this); }
+ void clear_stream() { stream_ = nullptr; }
+
protected:
static const int kClearOutChunkSize = 16384;
@@ -142,6 +144,7 @@ class TLSWrap : public AsyncWrap,
const uv_buf_t* buf,
uv_handle_type pending,
void* ctx);
+ static void OnDestructImpl(void* ctx);
void DoRead(ssize_t nread, const uv_buf_t* buf, uv_handle_type pending);