Browse Source

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 <info@bnoordhuis.nl>
v1.8.0-commit
Fedor Indutny 10 years ago
parent
commit
e90ed790c3
  1. 6
      src/tls_wrap.cc

6
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_);
}

Loading…
Cancel
Save