Skip to content

Commit e90ed79

Browse files
committed
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: #1154 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 056ed4b commit e90ed79

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/tls_wrap.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,13 @@ void TLSWrap::EncOut() {
306306
uv_buf_t buf[ARRAY_SIZE(data)];
307307
for (size_t i = 0; i < count; i++)
308308
buf[i] = uv_buf_init(data[i], size[i]);
309-
int r = stream_->DoWrite(write_req, buf, count, nullptr);
309+
int err = stream_->DoWrite(write_req, buf, count, nullptr);
310310
write_req->Dispatched();
311311

312312
// Ignore errors, this should be already handled in js
313-
if (!r)
313+
if (err)
314+
write_req->Dispose();
315+
else
314316
NODE_COUNT_NET_BYTES_SENT(write_size_);
315317
}
316318

0 commit comments

Comments
 (0)