Skip to content

Commit

Permalink
tls: fix leak on DoWrite() errors
Browse files Browse the repository at this point in the history
It is very unlikely to happen, but still the write request should be
disposed in case of immediate failure.

PR-URL: #1154
Reviewed-By: Ben Noordhuis <[email protected]>
  • Loading branch information
indutny committed Mar 14, 2015
1 parent 056ed4b commit e90ed79
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/tls_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
}

Expand Down

0 comments on commit e90ed79

Please sign in to comment.