From 7f4c95e16078451ee35dd61aba0f9d5fe99cc710 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Sat, 7 Mar 2015 11:41:22 -0500 Subject: [PATCH] tls: do not leak WriteWrap objects Kill WriteWrap instances that are allocated in `tls_wrap.cc` internally. Fix: https://github.com/iojs/io.js/issues/1075 PR-URL: https://github.com/iojs/io.js/pull/1090 Reviewed-By: Ben Noordhuis --- src/tls_wrap.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index a42e5faa70d..e3dc1e18853 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -305,6 +305,7 @@ void TLSWrap::EncOut() { for (size_t i = 0; i < count; i++) buf[i] = uv_buf_init(data[i], size[i]); int r = stream_->DoWrite(write_req, buf, count, nullptr); + write_req->Dispatched(); // Ignore errors, this should be already handled in js if (!r) @@ -314,6 +315,8 @@ void TLSWrap::EncOut() { void TLSWrap::EncOutCb(WriteWrap* req_wrap, int status) { TLSWrap* wrap = req_wrap->wrap()->Cast(); + req_wrap->~WriteWrap(); + delete[] reinterpret_cast(req_wrap); // Handle error if (status) {