Skip to content

tls: fix leak of WriteWrap+TLSWrap combination

Checklist
  • make -j8 test (UNIX), or vcbuild test nosign (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

tls

Description of change

Writing data to TLSWrap instance during handshake will result in it being queued in write_item_queue_. This queue won't get cleared up until the end of the handshake.

Technically, it gets cleared on ~TLSWrap invocation, however this won't ever happen because every WriteWrap holds a reference to the TLSWrap through JS object, meaning that they are doomed to be alive for eternity.

To breach this dreadful contract a knight shall embark from the close function to kill the dragon of memory leak with his magic spear of destroySSL.

destroySSL cleans up write_item_queue_ and frees SSL structure, both are good for memory usage.

PR-URL: https://github.com/nodejs/node/pull/9586 Reviewed-By: Ben Noordhuis info@bnoordhuis.nl


Backport of #9586, same PR should apply to v6.x too.

cc @TheAlphaNerd @nodejs/lts

Merge request reports

Loading