Skip to content

Commit 2ccc8f3

Browse files
committed
tls_wrap: fix this incredibly stupid leak
Always call `Done` on the WriteWrap, and ensure that `EncOut` will consume all data in clear_in_ and invoke queued callbacks. Fix: #1075 PR-URL: #1244 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent e74b5d2 commit 2ccc8f3

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/tls_wrap.cc

+8-4
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ TLSWrap::~TLSWrap() {
9090
MakePending();
9191

9292
// And destroy
93-
while (WriteItem* wi = pending_write_items_.PopFront())
94-
delete wi;
93+
InvokeQueued(UV_ECANCELED);
9594

9695
ClearError();
9796
}
@@ -310,10 +309,12 @@ void TLSWrap::EncOut() {
310309
write_req->Dispatched();
311310

312311
// Ignore errors, this should be already handled in js
313-
if (err)
312+
if (err) {
314313
write_req->Dispose();
315-
else
314+
InvokeQueued(err);
315+
} else {
316316
NODE_COUNT_NET_BYTES_SENT(write_size_);
317+
}
317318
}
318319

319320

@@ -335,6 +336,9 @@ void TLSWrap::EncOutCb(WriteWrap* req_wrap, int status) {
335336
// Commit
336337
NodeBIO::FromBIO(wrap->enc_out_)->Read(nullptr, wrap->write_size_);
337338

339+
// Ensure that the progress will be made and `InvokeQueued` will be called.
340+
wrap->ClearIn();
341+
338342
// Try writing more data
339343
wrap->write_size_ = 0;
340344
wrap->EncOut();

0 commit comments

Comments
 (0)