From e90ed790c340af01b0b9daa7dec6ff52caccde77 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Fri, 13 Mar 2015 21:40:48 -0700 Subject: [PATCH] tls: fix leak on `DoWrite()` errors It is very unlikely to happen, but still the write request should be disposed in case of immediate failure. PR-URL: https://github.com/iojs/io.js/pull/1154 Reviewed-By: Ben Noordhuis --- src/tls_wrap.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index 49523bc3b8..0fab952a2b 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -306,11 +306,13 @@ void TLSWrap::EncOut() { uv_buf_t buf[ARRAY_SIZE(data)]; 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); + int err = stream_->DoWrite(write_req, buf, count, nullptr); write_req->Dispatched(); // Ignore errors, this should be already handled in js - if (!r) + if (err) + write_req->Dispose(); + else NODE_COUNT_NET_BYTES_SENT(write_size_); }