Skip to content

Commit

Permalink
tls: do not leak WriteWrap objects
Browse files Browse the repository at this point in the history
Kill WriteWrap instances that are allocated in `tls_wrap.cc` internally.

Fix: #1075
PR-URL: #1090
Reviewed-By: Ben Noordhuis <[email protected]>
  • Loading branch information
indutny committed Mar 7, 2015
1 parent e763220 commit 7f4c95e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/tls_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -314,6 +315,8 @@ void TLSWrap::EncOut() {

void TLSWrap::EncOutCb(WriteWrap* req_wrap, int status) {
TLSWrap* wrap = req_wrap->wrap()->Cast<TLSWrap>();
req_wrap->~WriteWrap();
delete[] reinterpret_cast<char*>(req_wrap);

// Handle error
if (status) {
Expand Down

0 comments on commit 7f4c95e

Please sign in to comment.